【问题标题】:How to use insertId with big query streaming insert for each rows?如何为每一行使用带有 bigquery 流插入的插入 ID?
【发布时间】:2019-05-26 19:20:01
【问题描述】:

如何使用 insertId 和 Bigquery 流式插入 node.js 的每一行

const bigquery = new BigQuery({
  projectId: projectId,
});

// Inserts data into a table
await big query
  .dataset(datasetId)
  .table(tableId)
  .insert(rows);
console.log(`Inserted ${rows.length} rows`);

【问题讨论】:

标签: google-bigquery


【解决方案1】:

insertId 包含在 InsertionRow structure 中,即:

{
  "insertId": string,
  "json": {
    object
  }
}

有一个nodejs例子here,但基本上:

const rows = [
{
  insertId: '1',
  json: {
    INSTNM: 'Motion Picture Institute of Michigan',
    CITY: 'Troy',
    STABBR: 'MI'
  }
},
//...
];

正如document Graham 分享的那样:

为帮助确保数据一致性,您可以为每个 插入的行。 BigQuery 使用 insertId 属性对您的 尽力而为的数据。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-07-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多