如何为通过Google Apps脚本创建的BigQuery中的新表设置过期时间?

蒂莫加夫克

我有一个脚本,可用于通过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我在哪里出错以及如何解决?

am

问题:

您应该提供自纪元以来的毫秒数,而不是当前时刻。从BigQuery表格资源文档

expirationTime:可选。该表过期的时间,以epoch表示的毫秒数

解:

获取从纪元到当前时刻的毫秒数,并将其加上两个小时:

var expirationTime = 7200000 + new Date().getTime();

如有必要,在设置请求正文时将其解析为字符串:expirationTime: expirationTime.toString()

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何设置Big Query表的过期时间?

如何通过 Python 客户端库为 Google BigQuery 设置现有表到期时间?

如何比较 Google Apps 脚本中的时间

如何为Google表格制作循环脚本?

如何为Google图表设置事件?

如何为Google Chrome设置CLI标志?

如何为Google Colab创建视频设备?

如何通过Python使用Google Apps脚本?

如何通过迭代范围在Google Apps脚本中创建JSON对象

如何通过Apps脚本在Google表格中“清除格式”

如何为Google Glass创建基于时间的简单通知?

如何在 Google Apps 脚本中创建一个包含时间列的条形图

如何为Pushgateway设置指标过期的保留时间?

如何为缓存的 Ruby 搜索设置过期时间?

我每次打开Google工作表时如何为特定的单元格设置时间戳?

如何为Google Compute Engine设置GOOGLE_APPLICATION_CREDENTIALS?

R Shiny:如何为通过HTML创建的actionButton提供inputID

如何为Google Cloud PubSub中的订阅提供到期时间

如何为Google Glass创建深色的Google Maps图像?

如何为Google图表中的特定条形设置特定颜色?

您如何通过 Google Apps 脚本访问 Google Sheets API?

通过Google BigQuery中的select语句创建或更新表

如何通过API在Google Play中自动创建新应用

如何通过 Google Apps Script 获取 Google 日历的“位置”设置?

如何为上传到Google存储桶中的新图像设置默认的缓存控件

如何使用Google Apps脚本在googlespreadsheet中读取时间?

如何格式化此 Google Apps 脚本中的时间?

如何通过google-api-go-client将时间表设置为Google日历?

如何为新的Google Actions构建器构建Java Webhook