Skip to content

Commit

Permalink
Merge branch 'bigquery-udf-resources'
Browse files Browse the repository at this point in the history
  • Loading branch information
necnec committed Nov 28, 2016
2 parents 22d982a + dad9288 commit 9a16a8c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.19.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ Google BigQuery Enhancements

- The :func:`read_gbq` method has gained the ``dialect`` argument to allow users to specify whether to use BigQuery's legacy SQL or BigQuery's standard SQL. See the :ref:`docs <io.bigquery_reader>` for more details (:issue:`13615`).
- The :func:`~DataFrame.to_gbq` method now allows the DataFrame column order to differ from the destination table schema (:issue:`11359`).
- The :func:`read_gbq` method now allows passing user defined functions

.. _whatsnew_0190.errstate:

Expand Down
20 changes: 16 additions & 4 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):
def run_query(self, query, **kwargs):
try:
from googleapiclient.errors import HttpError
except:
Expand All @@ -395,6 +395,10 @@ def run_query(self, query):
}
}
}
query_config = kwargs.get('query_config')
if query_config is not None:
job_data['configuration']['query'].update(query_config)


self._start_timer()
try:
Expand Down Expand Up @@ -621,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'):
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 @@ -682,6 +687,13 @@ def read_gbq(query, project_id=None, index_col=None, col_order=None,
.. versionadded:: 0.19.0
**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
Returns
-------
df: DataFrame
Expand All @@ -698,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)
schema, pages = connector.run_query(query, **kwargs)
dataframe_list = []
while len(pages) > 0:
page = pages.pop()
Expand Down

0 comments on commit 9a16a8c

Please sign in to comment.