Google Bigquery BQ command line execute query from a file

后端 未结 6 580
天涯浪人
天涯浪人 2020-12-19 04:49

I use the bq command line tool to run queries, e.g:

bq query "select * from table"

What if I store the query in a file

6条回答
  •  北海茫月
    2020-12-19 05:19

    The other answers seem to be either outdated or needlessly brittle. As of 2019, bq query reads from stdin, so you can just redirect your file into it:

    bq query < myfile.sql
    

    Query parameters are passed like this:

    bq query --parameter name:type:value < myfile.sql
    

提交回复
热议问题