@@ -170,6 +170,8 @@ class Context(object):
170170 def __init__ (self ):
171171 self ._credentials = None
172172 self ._project = None
173+ # dialect defaults to None so that read_gbq can stop warning if set.
174+ self ._dialect = None
173175
174176 @property
175177 def credentials (self ):
@@ -216,6 +218,28 @@ def project(self):
216218 def project (self , value ):
217219 self ._project = value
218220
221+ @property
222+ def dialect (self ):
223+ """str: Default dialect to use in :func:`pandas_gbq.read_gbq`.
224+
225+ Allowed values for the BigQuery SQL syntax dialect:
226+
227+ ``'legacy'``
228+ Use BigQuery's legacy SQL dialect. For more information see
229+ `BigQuery Legacy SQL Reference
230+ <https://cloud.google.com/bigquery/docs/reference/legacy-sql>`__.
231+ ``'standard'``
232+ Use BigQuery's standard SQL, which is
233+ compliant with the SQL 2011 standard. For more information
234+ see `BigQuery Standard SQL Reference
235+ <https://cloud.google.com/bigquery/docs/reference/standard-sql/>`__.
236+ """
237+ return self ._dialect
238+
239+ @dialect .setter
240+ def dialect (self , value ):
241+ self ._dialect = value
242+
219243
220244# Create an empty context, used to cache credentials.
221245context = Context ()
@@ -728,12 +752,17 @@ def read_gbq(
728752 df: DataFrame
729753 DataFrame representing results of query.
730754 """
755+ global context
756+
757+ if dialect is None :
758+ dialect = context .dialect
759+
731760 if dialect is None :
732761 dialect = "legacy"
733762 warnings .warn (
734763 'The default value for dialect is changing to "standard" in a '
735- 'future version. Pass in dialect="legacy" to disable this '
736- " warning." ,
764+ 'future version. Pass in dialect="legacy" or set '
765+ 'pandas_gbq.context.dialect="legacy" to disable this warning.' ,
737766 FutureWarning ,
738767 stacklevel = 2 ,
739768 )
0 commit comments