Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix: pass custom delimiter from Table.from_csv to BigQuery load #1083

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions parsons/google/google_bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,15 @@ def copy(

self._validate_copy_inputs(if_exists=if_exists, data_type=data_type)

# If our source table is loaded from CSV with no transformations
# The original source file will be directly loaded to GCS
# We may need to pass along a custom delimiter to BigQuery
# Otherwise we use the default comma
if isinstance(tbl.table, petl.io.csv_py3.CSVView):
csv_delimiter = tbl.table.csvargs.get("delimiter", ",")
else:
csv_delimiter = ","

job_config = self._process_job_config(
job_config=job_config,
destination_table_name=table_name,
Expand All @@ -801,6 +810,7 @@ def copy(
allow_jagged_rows=allow_jagged_rows,
quote=quote,
custom_schema=schema,
csv_delimiter=csv_delimiter,
)

# Reorder schema to match table to ensure compatibility
Expand Down
Loading