1
votes

Is there a way using the NodeJS lib for BigQuery (https://github.com/googleapis/nodejs-bigquery) to delete rows? Could not find anything in documentation (https://googleapis.dev/nodejs/bigquery/latest/index.html)

It appears it should be possible using a DELETE statement via DML (https://cloud.google.com/bigquery/docs/reference/standard-sql/dml-syntax#delete_examples) but I could not find any examples of how to run this example via the NodeJS lib.

1

1 Answers

0
votes

If you know how to execute a SELECT query in BigQuery, you do the same to execute a DELETE query.

    const query = `SELECT name
      FROM \`bigquery-public-data.usa_names.usa_1910_2013\`
      WHERE state = 'TX'
      LIMIT 100`;

    // For all options, see https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/query
    const options = {
      query: query,
      // Location must match that of the dataset(s) referenced in the query.
      location: 'US',
    };

    // Run the query as a job
    const [job] = await bigquery.createQueryJob(options);

Just change the query in that example for DELETE FROM ____ WHERE ____.