Skip to content

Commit 8a38650

Browse files
committed
Added example configuration & job_configuration refactoring
1 parent 395c0e9 commit 8a38650

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

pandas/io/gbq.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -385,23 +385,25 @@ def run_query(self, query, **kwargs):
385385
_check_google_client_version()
386386

387387
job_collection = self.service.jobs()
388-
job_data = {
389-
'configuration': {
390-
'query': {
391-
'query': query,
392-
'useLegacySql': self.dialect == 'legacy'
393-
# 'allowLargeResults', 'createDisposition',
394-
# 'preserveNulls', destinationTable, useQueryCache
395-
}
388+
389+
job_config = {
390+
'query': {
391+
'query': query,
392+
'useLegacySql': self.dialect == 'legacy'
393+
# 'allowLargeResults', 'createDisposition',
394+
# 'preserveNulls', destinationTable, useQueryCache
396395
}
397396
}
398397
configuration = kwargs.get('configuration')
399398
if configuration is not None:
400399
if 'query' in configuration:
401-
job_data['configuration']['query']\
402-
.update(configuration['query'])
400+
job_config['query'].update(configuration['query'])
403401
else:
404-
job_data['configuration'] = configuration
402+
job_config = configuration
403+
404+
job_data = {
405+
'configuration': job_config
406+
}
405407

406408
self._start_timer()
407409
try:
@@ -692,6 +694,8 @@ def read_gbq(query, project_id=None, index_col=None, col_order=None,
692694
693695
**kwargs: Arbitrary keyword arguments
694696
configuration (dict): query config parameters for job processing.
697+
For example:
698+
configuration = {'query': {'useQueryCache': False}}
695699
For more information see `BigQuery SQL Reference
696700
<https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.query>`
697701

0 commit comments

Comments
 (0)