Skip to content

Commit

Permalink
Only set headers and delimiters for CSV exports in Google BigQuery hook
Browse files Browse the repository at this point in the history
  • Loading branch information
criccomini committed Feb 19, 2016
1 parent 7949218 commit e3ae241
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions airflow/contrib/hooks/bigquery_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'):
Expand Down

0 comments on commit e3ae241

Please sign in to comment.