-
Notifications
You must be signed in to change notification settings - Fork 16.2k
Description
Apache Airflow version: 1.10.*
BackPort Packages version: 2020.11.13rc1
What happened:
Although running the BigQueryGetDataOperator without specifying selected_fields appears to be successful, if you inspect table_data returned from hook.list_rows then it is just a list of empty sets.
[2020-11-11 15:10:30,665] {bigquery.py:483} INFO - Total extracted rows: 253
[(), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), ()]
[2020-11-11 15:10:30,679] {taskinstance.py:1143} INFO - Marking task as SUCCESS. dag_id=my-test-dag-v1.0, task_id=get-table, execution_date=20201101T000000, start_date=20201111T151030, end_date=20201111T151030
Adding some fields to the selected_fields argument, does correctly return data however.
[2020-11-11 15:13:37,608] {bigquery.py:483} INFO - Total extracted rows: 253
[(None, 'Anonymous Proxy'), (None, 'Satellite Provider'), (None, 'Asia/Pacific Region'), (None, 'European Union'), ('Pacific', 'American Samoa'), ('Pacific', 'Australia'), ('Pacific', 'Cook Islands'), ('Pacific', 'Fiji'), ('Pacific', 'Micronesia, Federated States of'), ('Pacific', 'Guam'), ('Pacific', 'Kiribati'), ('Pacific', 'Marshall Islands'), ('Pacific', 'Northern Mariana Islands'), ('Pacific', 'New Caledonia'), ('Pacific', 'Norfolk Island'), ('Pacific', 'Nauru'),
I think the offending code is between this two lines:
https://github.com/apache/airflow/blob/master/airflow/providers/google/cloud/hooks/bigquery.py#L1299
https://github.com/apache/airflow/blob/master/airflow/providers/google/cloud/hooks/bigquery.py#L1312
When no fields are submitted, it passes [] to the list_rows method in the BigQuery client which returns:
[Row((), {}), Row((), {}), Row((), {}), Row((), {}), Row((), {}), Row((), {}), Row((), {}), Row((), {}), Row((), {}), Row((), {}), Row((), {}), Row((), {}), Row((), {}), Row((), {}), Row((), {}), Row((), {}), Row((), {}), Row((), {}), Row((), {}), Row((), {}), Row((), {}), Row((), {}), Row((), {}), Row((), {}), Row((), {}), Row((), {}), Row((), {}), Row((), {}), Row((), {}), Row((), {}), Row((), {}), R
Changing hooks.bigquery.py so that only None or a non-empty list is passed will fix the issue.