Skip to content

Commit df5dec6

Browse files
committed
configuration->config & formatting
1 parent 99521aa commit df5dec6

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

doc/source/io.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4563,7 +4563,7 @@ destination DataFrame as well as a preferred column order as follows:
45634563
col_order=['col1', 'col2', 'col3'], projectid)
45644564
45654565
4566-
You can specify the query configuration as parameter
4566+
You can specify the query config as parameter
45674567

45684568
.. code-block:: python
45694569
@@ -4573,7 +4573,7 @@ You can specify the query configuration as parameter
45734573
}
45744574
}
45754575
data_frame = pd.read_gbq('SELECT * FROM test_dataset.test_table',
4576-
configuration=config, projectid)
4576+
config=config, projectid)
45774577
45784578
45794579
.. note::

pandas/io/gbq.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -394,17 +394,17 @@ def run_query(self, query, **kwargs):
394394
# 'preserveNulls', destinationTable, useQueryCache
395395
}
396396
}
397-
configuration = kwargs.get('configuration')
398-
if configuration is not None:
399-
if 'query' in configuration:
400-
if 'query' in configuration['query'] and query is not None:
401-
raise ValueError("Query statement can't be specified \
402-
inside config while it is specified as parameter")
403-
404-
job_config['query'].update(configuration['query'])
397+
config = kwargs.get('config')
398+
if config is not None:
399+
if 'query' in config:
400+
if 'query' in config['query'] and query is not None:
401+
raise ValueError("Query statement can't be specified "
402+
"inside config while it is specified "
403+
"as parameter")
404+
405+
job_config['query'].update(config['query'])
405406
else:
406407
raise ValueError("Only 'query' job type is supported")
407-
#job_config = configuration
408408

409409
job_data = {
410410
'configuration': job_config
@@ -698,10 +698,10 @@ def read_gbq(query, project_id=None, index_col=None, col_order=None,
698698
.. versionadded:: 0.19.0
699699
700700
**kwargs : Arbitrary keyword arguments
701-
configuration (dict): query config parameters for job processing.
701+
config (dict): query config parameters for job processing.
702702
For example:
703703
704-
configuration = {'query': {'useQueryCache': False}}
704+
config = {'query': {'useQueryCache': False}}
705705
706706
For more information see `BigQuery SQL Reference
707707
<https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.query>`

pandas/io/tests/test_gbq.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ def test_invalid_option_for_sql_dialect(self):
707707
private_key=_get_private_key_path())
708708

709709
# Test that a correct option for dialect succeeds
710-
# to make sure ValueError was due to invalid dialect
710+
# to make sure ValueError was due to invalid dialect
711711
gbq.read_gbq(sql_statement, project_id=_get_project_id(),
712712
dialect='standard', private_key=_get_private_key_path())
713713

@@ -746,10 +746,10 @@ def test_query_with_parameters(self):
746746
private_key=_get_private_key_path())
747747

748748
# Test that the query is successful because we have supplied
749-
# the correct query parameters via the 'configuration' option
749+
# the correct query parameters via the 'config' option
750750
df = gbq.read_gbq(sql_statement, project_id=_get_project_id(),
751751
private_key=_get_private_key_path(),
752-
configuration=config)
752+
config=config)
753753
tm.assert_frame_equal(df, DataFrame({'VALID_RESULT': [3]}))
754754

755755
def test_query_inside_configuration(self):
@@ -762,15 +762,15 @@ def test_query_inside_configuration(self):
762762
}
763763
}
764764
# Test that it can't pass query both
765-
# inside configuration and as parameter
765+
# inside config and as parameter
766766
with tm.assertRaises(ValueError):
767767
gbq.read_gbq(query_no_use, project_id=_get_project_id(),
768-
private_key=_get_private_key_path(),
769-
configuration=config)
768+
private_key=_get_private_key_path(),
769+
config=config)
770770

771771
df = gbq.read_gbq(None, project_id=_get_project_id(),
772-
private_key=_get_private_key_path(),
773-
configuration=config)
772+
private_key=_get_private_key_path(),
773+
config=config)
774774
tm.assert_frame_equal(df, DataFrame({'VALID_STRING': ['PI']}))
775775

776776
def test_configuration_without_query(self):
@@ -794,7 +794,7 @@ def test_configuration_without_query(self):
794794
with tm.assertRaises(ValueError):
795795
gbq.read_gbq(sql_statement, project_id=_get_project_id(),
796796
private_key=_get_private_key_path(),
797-
configuration=config)
797+
config=config)
798798

799799

800800
class TestToGBQIntegration(tm.TestCase):

0 commit comments

Comments
 (0)