@@ -262,7 +262,7 @@ def _insert_job(self, body_object):
262262 body = body_object
263263 ).execute ()
264264
265- def query (self , query , max_results = None , timeout = 0 , dry_run = False ):
265+ def query (self , query , max_results = None , timeout = 0 , dry_run = False , use_legacy_sql = None ):
266266 """Submit a query to BigQuery.
267267
268268 Parameters
@@ -278,6 +278,9 @@ def query(self, query, max_results=None, timeout=0, dry_run=False):
278278 If True, the query isn't actually run. A valid query will return an
279279 empty response, while an invalid one will return the same error
280280 message it would if it wasn't a dry run.
281+ use_legacy_sql : bool, optional. Default True.
282+ If False, the query will use BigQuery's standard SQL (https://cloud.google.com/bigquery/sql-reference/)
283+
281284
282285 Returns
283286 -------
@@ -298,8 +301,12 @@ def query(self, query, max_results=None, timeout=0, dry_run=False):
298301 'query' : query ,
299302 'timeoutMs' : timeout * 1000 ,
300303 'dryRun' : dry_run ,
301- 'maxResults' : max_results ,
304+ 'maxResults' : max_results
302305 }
306+
307+ if use_legacy_sql is not None :
308+ query_data ['useLegacySql' ] = use_legacy_sql
309+
303310 return self ._submit_query_job (query_data )
304311
305312 def get_query_schema (self , job_id ):
@@ -1027,6 +1034,7 @@ def write_to_table(
10271034 priority = None ,
10281035 create_disposition = None ,
10291036 write_disposition = None ,
1037+ use_legacy_sql = None
10301038 ):
10311039 """
10321040 Write query result to table. If dataset or table is not provided,
@@ -1055,6 +1063,9 @@ def write_to_table(
10551063 One of the JOB_CREATE_* constants
10561064 write_disposition : str, optional
10571065 One of the JOB_WRITE_* constants
1066+ use_legacy_sql:
1067+ If False, the query will use BigQuery's standard SQL (https://cloud.google.com/bigquery/sql-reference/)
1068+
10581069
10591070 Returns
10601071 -------
@@ -1084,6 +1095,9 @@ def write_to_table(
10841095 if use_query_cache is not None :
10851096 configuration ['useQueryCache' ] = use_query_cache
10861097
1098+ if use_legacy_sql is not None :
1099+ configuration ['useLegacySql' ] = use_legacy_sql
1100+
10871101 if priority :
10881102 configuration ['priority' ] = priority
10891103
0 commit comments