为BigQuery运行AppScript脚本时的神秘重复

时间:2018-08-01 02:44:32

标签: google-apps-script google-bigquery

以下代码应将基于查询的数据集附加到合并表,但是当前它正在复制该数据并将其附加。我认为这是Google方面的回归问题。任何帮助将不胜感激!

谢谢-马克

function runQuery1() {
  var configuration = {
     "query": {
     "useQueryCache": false,
     "destinationTable": {
        "projectId": "projectID",
        "datasetId": "datasetID",
       "tableId": "Consolidated"
      },
    "writeDisposition": "WRITE_APPEND",
    "allowLargeResults": true,
    "useLegacySql": false,
     "query": "SELECT cast(PARSE_DATETIME('%e/%m/%E4Y %H:%M',Date) as Date) as Date, Centre FROM Source.Temp",
     }
  };

  var job = {
    "configuration": configuration
   };

  var jobResult = BigQuery.Jobs.insert(job, "projectID");
 Logger.log(jobResult);
  }

runQuery1();

1 个答案:

答案 0 :(得分:0)

为防止重复运行作业,请考虑声明作业ID:

var configuration = {
  ...
  "jobReference": {
    "jobId": string,
  ...
}

从文档中

  

如果使用自己的作业ID,则可以随时检查作业的状态,并且可以重试相同的作业ID,以确保作业恰好启动一次。

https://cloud.google.com/bigquery/docs/running-jobs#generate-jobid