Skip to content

Commit

Permalink
Change parameter to kwargs
Browse files Browse the repository at this point in the history
  • Loading branch information
necnec committed Nov 28, 2016
1 parent 55bf05c commit dad9288
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions pandas/io/gbq.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ def process_insert_errors(self, insert_errors):

raise StreamingInsertError

def run_query(self, query, udf_resource_uri=None):
def run_query(self, query, **kwargs):
try:
from googleapiclient.errors import HttpError
except:
Expand All @@ -395,13 +395,9 @@ def run_query(self, query, udf_resource_uri=None):
}
}
}

if udf_resource_uri is not None:
if not isinstance(udf_resource_uri, list):
udf_resource_uri = [udf_resource_uri]

job_data['configuration']['query']['userDefinedFunctionResources'] = \
[{'resourceUri': uri} for uri in udf_resource_uri]
query_config = kwargs.get('query_config')
if query_config is not None:
job_data['configuration']['query'].update(query_config)


self._start_timer()
Expand Down Expand Up @@ -629,8 +625,9 @@ def _parse_entry(field_value, field_type):
return field_value


def read_gbq(query, project_id=None, index_col=None, col_order=None,
reauth=False, verbose=True, private_key=None, dialect='legacy', udf_resource_uri=None):
def read_gbq(query, project_id=None, index_col=None, col_order=None,
reauth=False, verbose=True, private_key=None, dialect='legacy',
**kwargs):
"""Load data from Google BigQuery.
THIS IS AN EXPERIMENTAL LIBRARY
Expand Down Expand Up @@ -690,9 +687,10 @@ def read_gbq(query, project_id=None, index_col=None, col_order=None,
.. versionadded:: 0.19.0
udf_resource_uri : list(str) or str (optional)
A code resource to load from a Google Cloud Storage URI.
Describes user-defined function resources used in the query.
**kwargs: Arbitrary keyword arguments
query_config (dict): query configuration parameters for job processing.
For more information see `BigQuery SQL Reference
<https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs#configuration.query>`
.. versionadded:: 0.19.0
Expand All @@ -712,7 +710,7 @@ def read_gbq(query, project_id=None, index_col=None, col_order=None,
connector = GbqConnector(project_id, reauth=reauth, verbose=verbose,
private_key=private_key,
dialect=dialect)
schema, pages = connector.run_query(query, udf_resource_uri)
schema, pages = connector.run_query(query, **kwargs)
dataframe_list = []
while len(pages) > 0:
page = pages.pop()
Expand Down

0 comments on commit dad9288

Please sign in to comment.