feluelle commented on a change in pull request #6180: [AIRFLOW-5549] Extended
BQ GetDataOperator to handle query params
URL: https://github.com/apache/airflow/pull/6180#discussion_r329067575
##########
File path: airflow/gcp/operators/bigquery.py
##########
@@ -285,37 +299,45 @@ def __init__(self,
self.dataset_id = dataset_id
self.table_id = table_id
+ self.start_index = start_index
self.max_results = max_results
+ self.page_token = page_token
self.selected_fields = selected_fields
self.gcp_conn_id = gcp_conn_id
self.delegate_to = delegate_to
- self.location = location
def execute(self, context):
self.log.info('Fetching Data from:')
self.log.info('Dataset: %s ; Table: %s ; Max Results: %s',
self.dataset_id, self.table_id, self.max_results)
hook = BigQueryHook(bigquery_conn_id=self.gcp_conn_id,
- delegate_to=self.delegate_to,
- location=self.location)
+ delegate_to=self.delegate_to)
conn = hook.get_conn()
cursor = conn.cursor()
response = cursor.get_tabledata(dataset_id=self.dataset_id,
table_id=self.table_id,
+ start_index=self.start_index,
max_results=self.max_results,
+ page_token=self.page_token,
selected_fields=self.selected_fields)
self.log.info('Total Extracted rows: %s', response['totalRows'])
rows = response['rows']
- table_data = []
+ table_rows = []
Review comment:
You could also just do:
```suggestion
table_rows = [
[fields['v'] for fields in dict_row['f']]
for dict_row in rows
]
```
(my preference)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services