2016-07-19 16 views
1

如果不存在具有该名称的表,则insertAll将失败。所以目前我们运行一个进程来创建表,然后在表存在时重新运行insertAll。如何在BigQuery中使用createDisposition insertAll

与其他所有BigQuery API调用一样,如果表不存在,您可以使用createDisposition创建表。

我的问题,是否有这样的insertAll?如果没有,为什么不呢!哈哈。

回答

1

退房templateSuffix属性insertAll
它做你所期望的

从技术文档

[实验]如果指定,把目标表为基础 模板,并插入行到一个名为 “{destination} {templateSuffix}”的实例表。 BigQuery将使用基本模板表的模式来管理实例表的创建。有关使用模板表时的注意事项,请参阅 https://cloud.google.com/bigquery/streaming-data-into-bigquery#template-tables

因此,请求应该类似于下面

var request = { 
    projectId: "yourProject", 
    datasetId: "yourDataset", 
    tableId: "yourTable", 
    resource: { 
    "kind": "bigquery#tableDataInsertAllRequest", 
    "skipInvalidRows": true, 
    "ignoreUnknownValues": true, 
    "templateSuffix": "YourTableSuffix", 
    "rows": ... 
    }, 

,导致目标表 - yourTableYourTableSuffix

+0

护理提供样本有效载荷? – Dovy

相关问题