【问题标题】:BigQuery: Questions on Delete and Update rows using nodejsBigQuery:关于使用 nodejs 删除和更新行的问题
【发布时间】:2018-10-05 19:33:47
【问题描述】:

我找到了很多 node.js 示例来查询并将数据插入 BigQuery,但没有找到任何示例或 API 说明如何删除和更新数据库中的行。我知道这些限制(自上次更改后 30 分钟等)。

我从vscode得到的唯一提示

bigQuery.dataset(dataset).table(table).deleteFromBigQuery('noIdea') 

但即使是 vscode 也无法给我更新的提示。

您知道任何关于此的 nodejs 文档吗?

我一直在寻找的一些资源 query examples by googleapisDMLs google Manual

【问题讨论】:

  • 您是要删除表中的行,还是要删除表本身?您可能想要执行 DELETE 或 DROP 查询。
  • 您能否发布您找到的有关如何运行查询的任何示例?我们可能可以将其修改为运行更新的版本
  • @FelipeHoffa,这是一个查询示例github.com/googleapis/nodejs-bigquery/blob/master/samples/…
  • @ElliottBrossard,我需要从查询中删除行,而不是表本身。

标签: node.js google-bigquery


【解决方案1】:

基于sync_query example:

async function runDeleteQuery(projectId) {
  // Imports the Google Cloud client library
  const BigQuery = require('@google-cloud/bigquery');

  /**
   * TODO(developer): Uncomment the following line before running the sample.
   */
  // const projectId = "your-project-id";

  // Modify this query however you need
  const sqlQuery = "DELETE FROM dataset.table WHERE condition;";

  // Creates a client
  const bigquery = new BigQuery({projectId});

  // Query options list: https://cloud.google.com/bigquery/docs/reference/v2/jobs/query
  const options = {
    query: sqlQuery,
    timeoutMs: 100000, // Time out after 100 seconds.
    useLegacySql: false, // Use standard SQL syntax for queries.
  };

  // Runs the query
  await bigquery.query(options);
}

另请参阅DELETE statement documentation

【讨论】:

猜你喜欢
  • 2020-10-12
  • 1970-01-01
  • 2020-11-09
  • 2018-01-31
  • 1970-01-01
  • 2017-08-16
  • 2018-02-06
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多