Google BigQuery, create a table from a query result

0 views
Skip to first unread message

Lukas Šalkauskas via StackOverflow

unread,
Jul 26, 2015, 10:08:05 PM7/26/15
to google-appengin...@googlegroups.com

ok, so we're using Google BigQuery via python API, my question is how to create a table (new one or overwrite old one) from a query results ? Some docs are here, but I can't find it usefull.

basically, we want to simulate

"SELEC ... INTO ..." from ANSI SQL.



Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/14622526/google-bigquery-create-a-table-from-a-query-result

Feczo via StackOverflow

unread,
Jul 26, 2015, 10:08:08 PM7/26/15
to google-appengin...@googlegroups.com

Take the SQL sample of

SELECT name,count FROM mydataset.babynames 
  WHERE gender = 'M' ORDER BY count DESC LIMIT 6 INTO mydataset.happyhalloween;

The easiest command line equivalent is

bq query --destination_table=mydataset.happyhalloween \ 
"SELECT name,count FROM mydataset.babynames WHERE gender = 'M' \
ORDER BY count DESC LIMIT 6"

See the documentation here: https://cloud.google.com/bigquery/bq-command-line-tool#createtablequery



Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/14622526/google-bigquery-create-a-table-from-a-query-result/31643957#31643957
Reply all
Reply to author
Forward
0 new messages