Skip to content

Commit 55a3ee6

Browse files
authored
Merge pull request #123 from davidquintana/master
Add ability use legacy SQL or standard SQL when creating a view
2 parents 95e666b + acaee13 commit 55a3ee6

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

bigquery/client.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ def patch_table(self, dataset, table, schema):
680680
else:
681681
return {}
682682

683-
def create_view(self, dataset, view, query):
683+
def create_view(self, dataset, view, query, use_legacy_sql=None):
684684
"""Create a new view in the dataset.
685685
686686
Parameters
@@ -691,6 +691,9 @@ def create_view(self, dataset, view, query):
691691
The name of the view to create
692692
query : dict
693693
A query that BigQuery executes when the view is referenced.
694+
use_legacy_sql : bool, optional
695+
If False, the query will use BigQuery's standard SQL
696+
(https://cloud.google.com/bigquery/sql-reference/)
694697
695698
Returns
696699
-------
@@ -710,6 +713,9 @@ def create_view(self, dataset, view, query):
710713
}
711714
}
712715

716+
if use_legacy_sql is not None:
717+
body['view']['useLegacySql'] = use_legacy_sql
718+
713719
try:
714720
view = self.bigquery.tables().insert(
715721
projectId=self.project_id,

0 commit comments

Comments
 (0)