From e3ae241706fb6fbdbd442dcf5bfb3412f8a3b128 Mon Sep 17 00:00:00 2001 From: Chris Riccomini Date: Fri, 19 Feb 2016 08:41:21 -0800 Subject: [PATCH] Only set headers and delimiters for CSV exports in Google BigQuery hook --- airflow/contrib/hooks/bigquery_hook.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/airflow/contrib/hooks/bigquery_hook.py b/airflow/contrib/hooks/bigquery_hook.py index e324ffb4a75a6..d70a629ccc484 100644 --- a/airflow/contrib/hooks/bigquery_hook.py +++ b/airflow/contrib/hooks/bigquery_hook.py @@ -225,11 +225,16 @@ def run_extract(self, source_dataset_table, destination_cloud_storage_uris, comp 'compression': compression, 'destinationUris': destination_cloud_storage_uris, 'destinationFormat': export_format, - 'fieldDelimiter': field_delimiter, - 'printHeader': print_header, } } + if export_format == 'CSV': + # Only set fieldDelimiter and printHeader fields if using CSV. + # Google does not like it if you set these fields for other export + # formats. + configuration['extract']['fieldDelimiter'] = field_delimiter + configuration['extract']['printHeader'] = print_header + return self.run_with_configuration(configuration) def run_copy(self, source_dataset_tables, destination_project_dataset_table, write_disposition='WRITE_EMPTY', create_disposition='CREATE_IF_NEEDED'):