Skip to content
This repository was archived by the owner on Sep 3, 2022. It is now read-only.

Add ability to set the default BigQuery SQL dialect #94

Merged
merged 1 commit into from
Nov 18, 2016
Merged

Add ability to set the default BigQuery SQL dialect #94

merged 1 commit into from
Nov 18, 2016

Conversation

parthea
Copy link
Contributor

@parthea parthea commented Nov 17, 2016

Closes #93

By default, Datalab will set the BigQuery SQL dialect to legacy for all queries.

Use set_datalab_bq_dialect('standard') to set the default BigQuery SQL dialect to Standard SQL for the notebook, and datalab_bq_dialect() to read the BigQuery SQL dialect specified for the notebook.

Note: If the dialect parameter is provided on a per query basis, then the dialect parameter for that query will be honored (i.e. we will ignore the notebook default).

For example,
If the SQL dialect for the notebook is set to legacy, the following query will still execute successfully since the dialect is specified on a per query basis.

%%sql -d standard
WITH UniqueNames2013 AS
(SELECT DISTINCT name
  FROM `bigquery-public-data.usa_names.usa_1910_2013`
  WHERE Year = 2013)
SELECT COUNT(*) FROM UniqueNames2013

@qimingj
Copy link
Contributor

qimingj commented Nov 18, 2016

Thanks Anthonios!

We plan to make standard SQL the default so maybe we don't need the global dialect setting. What do you think?

@qimingj
Copy link
Contributor

qimingj commented Nov 18, 2016

Assigning to Chris.

@parthea
Copy link
Contributor Author

parthea commented Nov 18, 2016

My initial thought is that a global setting could be useful regardless of whether legacy or standard is the default.

My feeling is that with this change there will be less impact to existing users after changing the default dialect to Standard SQL. They would simply have set_datalab_bq_dialect('legacy') in a cell in their notebook, as opposed to setting the dialect to 'legacy' on a per-query basis for all queries.

@parthea
Copy link
Contributor Author

parthea commented Nov 18, 2016

We plan to make standard SQL the default

Can I go ahead and make that change in this PR?

@qimingj
Copy link
Contributor

qimingj commented Nov 18, 2016

My only concern is that we are adding it to context class, and in the future we will probably need to remove it so it will become a backward compatibility issue.

Can we move the setting to a global variable such as datalab.bigquery._dialect, so you could still use it but it will be easier to remove in the future?

@parthea
Copy link
Contributor Author

parthea commented Nov 18, 2016

Can we move the setting to a global variable such as datalab.bigquery._dialect, so you could still use it but it will be easier to remove in the future?

Yes. I'll make this change. Let me know if it is ok to change the default dialect to Standard SQL here. If we don't want to make the change now, I expect it will only be a 1 line change to make standard SQL default in another PR.

@qimingj
Copy link
Contributor

qimingj commented Nov 18, 2016

Let's not change the default dialect since it is another breaking change.

@parthea
Copy link
Contributor Author

parthea commented Nov 18, 2016

The changes in this PR are ready for review.

@chmeyers chmeyers merged commit 3ae2bc9 into googledatalab:master Nov 18, 2016
@parthea parthea deleted the issues/issue_93 branch November 18, 2016 20:51
@qimingj
Copy link
Contributor

qimingj commented Nov 18, 2016

Thanks Anthonios!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants