Javascript未终止的字符串文字错误

时间:2018-10-16 11:16:55

标签: javascript google-apps-script google-bigquery

我想知道是否有人可以帮助我。

我一直在努力寻求在这里获得的帮助:Dynamic Table and Dataset in Scheduled BigQuery Job

我已经尝试运行代码,并且我认为这是一个固有的问题,因为当我运行下面的代码时,我在此行收到错误消息:

 "query": "SELECT

错误是“未终止的字符串文字”

    function runQuery() {

          var yesterday = Utilities.formatDate(new Date(), "GMT", "dd-MM-yyyy'T'HH:mm:ss'Z'");

          var configuration = {
          "query": {
            "useQueryCache": false,
            "destinationTable": {
                  "projectId": "project_name_obfuscated",
                  "datasetId": "project_114151_shared",
                  "tableId": "test123"
                },
            "writeDisposition": "WRITE_TRUNCATE",
            "createDisposition": "CREATE_IF_NEEDED",
            "allowLargeResults": true,
            "query": "SELECT * 
FROM (SELECT hits.page.pagePath
FROM
[project:dataset.ga_sessions_20181015] 
WHERE
REGEXP_MATCH( hits.page.pagePath, r'\?email=.*@.*\.*')),
(SELECT
hits.eventInfo.eventLabel
FROM
[project:dataset.ga_sessions_20181015] 
WHERE
hits.eventInfo.eventAction = 'end-client,role,decision')"
      }
    };

    var job = {
        "configuration": configuration
    };

    var jobResult = BigQuery.Jobs.insert(job, "project_name_obfuscated");

    var jobId = jobResult.jobReference.jobId;

    // The job might not actually be done; wait until it is marked
    // complete.
    var sleepTimeMs = 500;
    while (true) {
        Utilities.sleep(sleepTimeMs);
        sleepTimeMs *= 2;
        queryResults = BigQuery.Jobs.getQueryResults(projectId, jobId, {
          "maxResults": 10000);
        if (!queryResults.jobComplete) {
          break;
        }
    }

我已经看过各种教程,并尝试添加'+解决方案,使该行成为“查询”:'SELECT +

但是我仍然无法运行脚本。

有人可以指出我哪里出问题了吗?

非常感谢和问候!

1 个答案:

答案 0 :(得分:0)

用户TheMaster在其评论中指出,该错误来自格式错误的多行字符串:

  

好吧,那是多行。 <Route path="/products" component={products} /> <Route path="/compareproducts" component={CompareProducts} /> 不在行1上终止。使用"\ developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/…来加入他们的应用程序脚本不是ES2015。所以你不能使用``

所以代码应该看起来像这样:

+