这个问题似乎有时难以复制,但随后会反复出现,这让我觉得它可能与配额有关,但我看不到它们中的任何一个设置在我们的账户上。 / p>
var myQuery = 'SELECT * FROM [' + myProjectId + ':' + myDatasetId + '.' + historyTable + '] WHERE ID NOT IN (SELECT ID FROM [' + myProjectId + ':' + myDatasetId + '.' + federatedTable + '])'
// Overwrite the history table with a version with only the records that are NOT in federated
var job = {
configuration: {
query: {
query: myQuery,
maximumBillingTier: "2",
writeDisposition:'WRITE_TRUNCATE',
useQueryCache: true,
allowLargeResults: true,
destinationTable: {
projectId: myProjectId,
datasetId: myDatasetId,
tableId: historyTable
}}
}};
var queryResults = BigQuery.Jobs.insert(job, myProjectId);
var jobId = queryResults.jobReference.jobId;
// Wait until that job completes
// Check on status of the Query Job.
var sleepTimeMs = 500;
while (!queryResults.jobComplete) {
Utilities.sleep(sleepTimeMs);
queryResults = BigQuery.Jobs.getQueryResults(myProjectId, jobId);
Logger.log("Not Done");
}
错误发生在
行上queryResults = BigQuery.Jobs.getQueryResults(myProjectId, jobId);
该表有91列,大约25,000行,所以应该不会接近128mb的响应限制。
已阅读每个类似的Stackoverflow问题并尝试了所有内容!
答案 0 :(得分:2)
看起来您想要运行一个查询作业,该作业将结果写入指定的目标表。但是,在你的循环中,每次调用时,你都会调用getQueryResults
will request all the results查询本身。这就是造成413的原因。
我认为这不是你真正想做的事情。
相反,只需轮询job.status.state
即可获得job resource以确定何时完成。这不会将所有结果都拉到网上。例如:
function runQuery() {
var projectId = 'XXXXXX';
var myQuery = 'SELECT TOP(word, 300) AS word, COUNT(*) AS word_count ' +
'FROM publicdata:samples.shakespeare WHERE LENGTH(word) > 10;'
var job = {
configuration: {
query: {
query: myQuery,
writeDisposition:'WRITE_TRUNCATE',
useQueryCache: true,
allowLargeResults: true,
destinationTable: {
projectId: 'XXXXXX',
datasetId: 'test',
tableId: 'test_table'
}}
}};
var job = BigQuery.Jobs.insert(job, projectId);
Logger.log(job.status.state);
var jobId = job.jobReference.jobId;
// Check on status of the Query Job.
var sleepTimeMs = 500;
while (job.status.state !== 'DONE') {
Utilities.sleep(sleepTimeMs);
job = BigQuery.Jobs.get(projectId, jobId);
Logger.log(job.status.state);
}
}