适用于BigQuery的Google Apps脚本(标准SQL)-NaN

时间:2018-09-12 02:53:30

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

面对我的应用程序脚本似乎正在运行的一些问题,但是只有选定的行,我不确定为什么。想知道标准SQL和某些参数是否可能是一个问题。这是我的代码

function runQuery() {
  var configuration = {
    query: {
    useQueryCache: false,
    destinationTable: {
          projectId: "projectA",
          datasetId: "datasetA",
          tableId: "NewTable"
        },
    writeDisposition: "WRITE_TRUNCATE",
    createDisposition: "CREATE_IF_NEEDED",
    allowLargeResults: true,
    useLegacySql: false,
    query: "WITH a AS" + 
      "(SELECT Date, Month, Quarter, Week, Year FROM Dataset.Table1`)," + 
      "b AS "+
      "(SELECT * FROM `Dataset.Table2`)," +
      "c AS "+
      "(SELECT * FROM `Dataset.Table3`) " + 
      "SELECT Date, Month, Quarter, Week, Year, .... FROM a" + 
      "LEFT JOIN b ON a.x = b.x LEFT JOIN c ON a.x = c.x"
    }
  };

  var job = {
    configuration: configuration
  };

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

(已更改变量和表名以使内容空白,但已显示了代码的一般结构)

SQL代码本身可在BigQuery上使用,因此问题不在于查询中的错误。

当我尝试运行此代码时,BigQuery上的日志似乎显示执行的代码只是代码的最后两行,前面是NaN

NaNSELECT Date, Month, Quarter, Week, Year, .... FROM a LEFT JOIN b ON a.x = b.x LEFT JOIN c ON a.x = c.x

对此表示感谢。谢谢

1 个答案:

答案 0 :(得分:0)

我认为,您在第

行下缺少回车号
  "(SELECT Date, Month, Quarter, Week, Year FROM Dataset.Table1`)," +   

应该是

  "(SELECT Date, Month, Quarter, Week, Year FROM `Dataset.Table1`)," +