2016-07-19 47 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

相關問題