From 269685c2e3ffad9a02d0e002b8ca16555b4507be Mon Sep 17 00:00:00 2001 From: Piotr Chromiec Date: Tue, 11 Jul 2017 18:04:29 +0200 Subject: [PATCH] ENH: BQ Job Id in verbose output (#70) * ENH: BQ Job Id in verbose output * changelog entry --- docs/source/changelog.rst | 3 ++- pandas_gbq/gbq.py | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst index 05981843..a69bda99 100644 --- a/docs/source/changelog.rst +++ b/docs/source/changelog.rst @@ -7,7 +7,8 @@ Changelog - Drop support for Python 3.4 (:issue:`40`) - The dataframe passed to ```.to_gbq(...., if_exists='append')``` needs to contain only a subset of the fields in the BigQuery schema. (:issue:`24`) - Use the `google-auth `__ library for authentication because oauth2client is deprecated. (:issue:`39`) -- ``read_gbq`` now has a ``auth_local_webserver`` boolean argument for controlling whether to use web server or console flow when getting user credentials. Replaces `--noauth_local_webserver` command line argument (:issue:`35`) +- ``read_gbq`` now has a ``auth_local_webserver`` boolean argument for controlling whether to use web server or console flow when getting user credentials. Replaces `--noauth_local_webserver` command line argument. (:issue:`35`) +- ``read_gbq`` now displays the BigQuery Job ID in verbose output. (:issue:`70`) 0.1.6 / 2017-05-03 ------------------ diff --git a/pandas_gbq/gbq.py b/pandas_gbq/gbq.py index b9bb9498..5fa78153 100644 --- a/pandas_gbq/gbq.py +++ b/pandas_gbq/gbq.py @@ -514,7 +514,7 @@ def run_query(self, query, **kwargs): self._print('Requesting query... ', end="") query_reply = job_collection.insert( projectId=self.project_id, body=job_data).execute() - self._print('ok.\nQuery running...') + self._print('ok.') except (RefreshError, ValueError): if self.private_key: raise AccessDenied( @@ -527,13 +527,15 @@ def run_query(self, query, **kwargs): self.process_http_error(ex) job_reference = query_reply['jobReference'] + job_id = job_reference['jobId'] + self._print('Job ID: %s\nQuery running...' % job_id) while not query_reply.get('jobComplete', False): self.print_elapsed_seconds(' Elapsed', 's. Waiting...') try: query_reply = job_collection.getQueryResults( projectId=job_reference['projectId'], - jobId=job_reference['jobId']).execute() + jobId=job_id).execute() except HttpError as ex: self.process_http_error(ex) @@ -584,7 +586,7 @@ def run_query(self, query, **kwargs): try: query_reply = job_collection.getQueryResults( projectId=job_reference['projectId'], - jobId=job_reference['jobId'], + jobId=job_id, pageToken=page_token).execute() except HttpError as ex: self.process_http_error(ex)