You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by cr...@apache.org on 2017/12/11 23:14:24 UTC

incubator-airflow git commit: [AIRFLOW-1892] Modify BQ hook to extract data filtered by column

Repository: incubator-airflow
Updated Branches:
  refs/heads/master 8ba86072f -> c6f46b102


[AIRFLOW-1892] Modify BQ hook to extract data filtered by column

Closes #2855 from kaxil/patch-2


Project: http://git-wip-us.apache.org/repos/asf/incubator-airflow/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-airflow/commit/c6f46b10
Tree: http://git-wip-us.apache.org/repos/asf/incubator-airflow/tree/c6f46b10
Diff: http://git-wip-us.apache.org/repos/asf/incubator-airflow/diff/c6f46b10

Branch: refs/heads/master
Commit: c6f46b1024d49e5d462fd16fb8b0aed032351720
Parents: 8ba8607
Author: Kaxil Naik <ka...@gmail.com>
Authored: Mon Dec 11 15:13:56 2017 -0800
Committer: Chris Riccomini <cr...@apache.org>
Committed: Mon Dec 11 15:14:00 2017 -0800

----------------------------------------------------------------------
 airflow/contrib/hooks/bigquery_hook.py | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/c6f46b10/airflow/contrib/hooks/bigquery_hook.py
----------------------------------------------------------------------
diff --git a/airflow/contrib/hooks/bigquery_hook.py b/airflow/contrib/hooks/bigquery_hook.py
index 3b4ce0f..d64c2a1 100644
--- a/airflow/contrib/hooks/bigquery_hook.py
+++ b/airflow/contrib/hooks/bigquery_hook.py
@@ -720,19 +720,18 @@ class BigQueryBaseCursor(LoggingMixin):
             .execute()
         return tables_resource['schema']
 
-    def get_tabledata(self,
-                      dataset_id,
-                      table_id,
-                      max_results=None,
-                      page_token=None,
+    def get_tabledata(self, dataset_id, table_id,
+                      max_results=None, selected_fields=None, page_token=None,
                       start_index=None):
         """
-        Get the data of a given dataset.table.
+        Get the data of a given dataset.table and optionally with selected columns.
         see https://cloud.google.com/bigquery/docs/reference/v2/tabledata/list
 
         :param dataset_id: the dataset ID of the requested table.
         :param table_id: the table ID of the requested table.
         :param max_results: the maximum results to return.
+        :param selected_fields: List of fields to return (comma-separated). If
+            unspecified, all fields are returned.
         :param page_token: page token, returned from a previous call,
             identifying the result set.
         :param start_index: zero based index of the starting row to read.
@@ -741,6 +740,8 @@ class BigQueryBaseCursor(LoggingMixin):
         optional_params = {}
         if max_results:
             optional_params['maxResults'] = max_results
+        if selected_fields:
+            optional_params['selectedFields'] = selected_fields
         if page_token:
             optional_params['pageToken'] = page_token
         if start_index: