Use .bigqueryrc to set BigQuery global configuration
I started using the nice vim plugin vim-dadbod which allows to fire database queries and see the output inside vim/neovim.
While setting it up to work with BigQuery I ran into the error coming from the fact that BigQuery’s format to name a table has changed in time and bq
uses the old one (legacy) as default. The legacy format reads: project:dataset.table
(notice :
) while the newer format goes by: project.dataset.table
(with .
instead).
It turns out there is a file called .bigqueryrc
where you can set a global configuration and tell bq
(the command line tool to interact with BigQuery in the terminal) to use the newer format by setting the flag use_legacy_sql=false
:
credential_file = /path/to/some/file.json
project_id = name-of-your-default-project
[query]
use_legacy_sql = false
The CLI-tool bq
also accepts the file as optional argument so you can pass custom config for a query. If you run bq --help
you’ll see:
--bigqueryrc: Path to configuration file. The configuration file specifies new
defaults for any flags, and can be overrridden by specifying the flag on the
command line. If the --bigqueryrc flag is not specified, the BIGQUERYRC
environment variable is used. If that is not specified, the path
"~/.bigqueryrc" is used.
(default: '~/.bigqueryrc')
Read more about that in the official documetation.
/Fin
Any bugs, questions, comments, suggestions? Ping me on twitter or drop me an e-mail (fabridamicelli at gmail).
Share this article on your favourite platform: