Skip to content
Advertisement

BigQuery cli bq how to use EXECUTE IMMEDIATE script

I would like to use two SQL scripts to create and update a table in BigQuery using bq query command. Here are the two scripts :

1- Creating the table

2- updating the table

When using these two scripts as queries with the bq query command, I have got an error :

Is there any other way to do that?

Thank you

Advertisement

Answer

The default query dialect in the bq command-line tool is legacy SQL. You need to switch to the standard SQL dialect to be able to run scripts:

  1. --use_legacy_sql=false or --nouse_legacy_sql flag to your command-line statement.
  2. prefix your sql with #standardSQL

enter image description here

You can also set standard SQL as your default. See here.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement