Skip to content

Commit

Permalink
Merge pull request #1039 from criccomini/set-headers-only-for-csv
Browse files Browse the repository at this point in the history
Only set headers and delimiters for CSV exports in Google BigQuery hook
  • Loading branch information
r39132 committed Feb 19, 2016
2 parents 7949218 + e3ae241 commit 8be0296
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 8be0296

Please sign in to comment.