BigQuery Node.js API startQuery不会将数据注入到destinationTable中

考虑下面的BQ查询:

const sourceQuery = '#standardSQL SELECT station_id, time FROM bryans_bike_analysis_data.2016_status_data ' + 'WHERE SAFE_CAST(bikes_available as INT64)=0 AND SAFE_CAST(docks_available AS INT64)=0' + 'GROUP BY station_id, time'; 

并考虑以下代码(放置在Google云端函数中 – 删除了一些内容,保持简短):

 bqSource.startQuery({ destination: bqDest.dataset(destDataset).table(destTable), query: sourceQuery }, function(err, job) { if (!err) { console.log("Succesfully initialized query"); job.getQueryResults(function(err, rows, apiResponse) { if (!err) { console.log("Successfully completed inner"); console.log(apiResponse); } else { console.log(err); console.log(apiResponse); res.status(500).end(); } }); } else { console.log(err); res.status(500).end(); } }); 

该文档使我相信查询应该执行,然后结果应该被放置到表中(在一个单独的项目中)按照目标属性指定。 但是,这是返回的错误:

 errors: [ { domain: 'global', reason: 'invalidQuery', message: '1.195 - 1.195: No query found.', locationType: 'other', location: 'query' } ], response: undefined, message: '1.195 - 1.195: No query found.' } 

当我查看日志时,它看起来像是对我的目标项目的BQ进行的插入调用,实际上是我的项目中的getqueryresults调用正在获取错误。 在我的源项目错误里面的日志是:

  jobGetQueryResultsResponse: { job: { jobConfiguration: { query: { createDisposition: "CREATE_IF_NEEDED" defaultDataset: { } destinationTable: { datasetId: "destination_bq_cp_test" projectId: "armalavage-test" tableId: "bikes_available" } query: "#standardSQL SELECT station_id, time FROM bryans_bike_analysis_data.2016_status_data WHERE SAFE_CAST(bikes_available as INT64)=0 AND SAFE_CAST(docks_available AS INT64)=0GROUP BY station_id, time" writeDisposition: "WRITE_EMPTY" } } 

我假定目标数据集是在查询本身内设置的。 为什么不解决?

你的查询string的问题是,它只是一个以#开头的行,被视为注释 – 因此错误信息 – No query found