Google bigquery 如何将insertId与每行的大查询流式插入一起使用?

Google bigquery 如何将insertId与每行的大查询流式插入一起使用?,google-bigquery,Google Bigquery,如何通过node.js将insertId与Bigquery流式插入一起用于每一行 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`);

如何通过node.js将insertId与Bigquery流式插入一起用于每一行

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`);

insertId包含在InsertionRow中,即:

{
  "insertId": string,
  "json": {
    object
  }
}
有一个nodejs示例,但基本上:

const rows = [
{
  insertId: '1',
  json: {
    INSTNM: 'Motion Picture Institute of Michigan',
    CITY: 'Troy',
    STABBR: 'MI'
  }
},
//...
];
正如格雷厄姆分享的:

为了帮助确保数据一致性,您可以为每个 插入的行。BigQuery使用insertId属性来消除重复 尽最大努力收集数据


你好!欢迎来到SO。你读过这个吗?