@@ -170,6 +170,8 @@ class Context(object):
170
170
def __init__ (self ):
171
171
self ._credentials = None
172
172
self ._project = None
173
+ # dialect defaults to None so that read_gbq can stop warning if set.
174
+ self ._dialect = None
173
175
174
176
@property
175
177
def credentials (self ):
@@ -216,6 +218,28 @@ def project(self):
216
218
def project (self , value ):
217
219
self ._project = value
218
220
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
+
219
243
220
244
# Create an empty context, used to cache credentials.
221
245
context = Context ()
@@ -728,12 +752,17 @@ def read_gbq(
728
752
df: DataFrame
729
753
DataFrame representing results of query.
730
754
"""
755
+ global context
756
+
757
+ if dialect is None :
758
+ dialect = context .dialect
759
+
731
760
if dialect is None :
732
761
dialect = "legacy"
733
762
warnings .warn (
734
763
'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.' ,
737
766
FutureWarning ,
738
767
stacklevel = 2 ,
739
768
)
0 commit comments