1
votes

I would like to do as described here:

https://cloud.google.com/bigquery/docs/tables#creating_a_table_from_a_query_result

However I'm using the node.js client libraries for which there is no documentation there. Possibly this is not supported by the node.js client libraries, or possibly it's not yet documented for node.js.

===Alternative solution===

An alterative solution, as suggested by @ElliottBrossard is to use the create table statement documented here:

https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#create_table_statement

as follows

bigQuery.query({
  query: 'CREATE OR REPLACE TABLE `<project_name>.<dataset_name>.<output_table_name>` AS SELECT * FROM `<project_name>.<dataset_name>.<input_table_name>*`',
  useLegacySql: false, // Use standard SQL syntax for queries.
})
1
No I hadn't. That seems like it might work. Thanks - Sivart
That does exactly what I wanted. Very much appreciated. @ElliottBrossard - Sivart
Great! Consider posting a snippet of the code that you used as an answer to help anyone with the same question in the future. - Elliott Brossard

1 Answers

0
votes

Besides the solution proffered in the question, there is native support for writing query results to a table. BigQuery.createQueryjob will write results to a new table. The name of the table is specified in the destination property of the options object.

An example is online as part of the documentation.