Skip to content
Snippets Groups Projects
Commit 0aa2df9e authored by Cam Saül's avatar Cam Saül Committed by GitHub
Browse files

Merge pull request #4433 from metabase/allow-bigquery-standard-sql

Allow BigQuery standard SQL (inspired by @gitram)
parents d5989b6d 009d9d12
Branches
Tags v0.12.0
No related merge requests found
......@@ -7,15 +7,23 @@ Starting in v0.15.0 Metabase provides a driver for connecting to BigQuery direct
1. make sure you have a [Google Cloud Platform](https://cloud.google.com/) account with a Project you would like to use in Metabase.
* Start by giving this connection a __Name__ and providing your Google Cloud Platform __Project ID__ along with your desired BigQuery __Dataset ID__. If you don't have a dataset and want to play around with something we recommend copying one of the [sample tables](https://cloud.google.com/bigquery/sample-tables)
![basicfields](../images/bigquery_basic.png)
![Basic Fields](../images/bigquery_basic.png)
* Follow the `Click here` link provided below the __Client ID__ field which will open a new browser tab and guide you through the process of generating OAuth 2.0 credentials for Metabase. Make sure to choose `Other` for your application type.
![clientid](../images/bigquery_clientid.png)
![Client ID](../images/bigquery_clientid.png)
* take the resulting client ID and client secret and copy them over to Metabase.
![clientid](../images/bigquery_clientdetails.png)
![Client Details](../images/bigquery_clientdetails.png)
* Now follow the link below the __Auth Code__ field for `Click here to get an auth code` which will open a new browser window and authorize your credentials for a BigQuery access token to use the api. Simply click the `Allow` button.
![clientid](../images/bigquery_authcode.png)
![Generating an Auth Code](../images/bigquery_authcode.png)
* Copy the resulting code provided into the __Auth Code__ field in Metabase.
![clientid](../images/bigquery_copycode.png)
![Copying the Auth Code](../images/bigquery_copycode.png)
* Click the `Save` button!
Metabase will now begin inspecting your BigQuery Dataset and finding any tables and fields to build up a sense for the schema. Give it a little bit of time to do its work and then you're all set to start querying.
## Using Standard SQL
By default, Metabase tells BigQuery to interpret queries as [Legacy SQL](https://cloud.google.com/bigquery/docs/reference/legacy-sql). If you prefer using
[Standard SQL](https://cloud.google.com/bigquery/docs/reference/standard-sql/) instead, you can tell Metabase to do so by including a `#standardSQL` directive at the beginning of your query:
![Enabling Standard SQL](../images/bigquery_standard_sql.png)
docs/administration-guide/images/bigquery_standard_sql.png

12.4 KiB

......@@ -121,6 +121,8 @@
{:pre [client (seq project-id) (seq query-string)]}
(let [request (doto (QueryRequest.)
(.setTimeoutMs (* query-timeout-seconds 1000))
;; if the query contains a `#standardSQL` directive then use Standard SQL instead of legacy SQL
(.setUseLegacySql (not (s/includes? query-string "#standardSQL")))
(.setQuery query-string))]
(google/execute (.query (.jobs client) project-id request)))))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment