I am using the Bigquery command line tool to query data from a Bigquery table.
My query statement is very long.
Is there a way to save the long query statement in a file and pass the file name to the Bigquery command line tool?
Thank you.
BigQuery allows you to run complex analytical queries on large sets of data. Queries are requests for data that can include calculation, modification, merging, and other manipulations with data. Let's say, in Google Sheets, you can also query data sets using the QUERY function.
You can run the bq command-line tool in an interactive shell where you don't need to prefix the commands with bq . To start interactive mode, enter bq shell . After launching the shell, the prompt changes to the ID of your default project. To exit interactive mode, enter exit .
The bq command-line tool accepts the following formats for setting boolean flags. This document uses the -- FLAGNAME = VALUE format for boolean flags. All boolean flags are optional; if a boolean flag is not present, then BigQuery uses the flag's default value.
You can use this:
cat query.txt | bq query
Just use cat
in tick marks. Switch the double quotes to single quotes if needed.
bq query "`cat query.txt`"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With