我有一个脚本,可用于通过Google Apps脚本项目创建新的Google BigQuery表。当我使用默认到期时间运行它时,它运行良好。但是现在我想将到期时间设置为等于2小时(7200000ms)
function createNewTable(tableId){
var table = {
expirationTime: "7200000",
tableReference: {
projectId: projectId,
datasetId: datasetId,
tableId: tableId
}
}
table = BigQuery.Tables.insert(table, projectId, datasetId);
console.info('Table created: %s', table.id);
}
由于错误而无法使用API call to bigquery.tables.insert failed with error: Expiration time must be at least 1 seconds in the future
。我在哪里出错以及如何解决?
您应该提供自纪元以来的毫秒数,而不是当前时刻。从BigQuery表格资源文档:
expirationTime:可选。该表过期的时间,以epoch表示的毫秒数。
获取从纪元到当前时刻的毫秒数,并将其加上两个小时:
var expirationTime = 7200000 + new Date().getTime();
如有必要,在设置请求正文时将其解析为字符串:expirationTime: expirationTime.toString()
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句