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

Fixes datamill-co/target-snowflake#21 #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
7 changes: 5 additions & 2 deletions target_snowflake/snowflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ def add_table_mapping(self, cur, from_path, metadata):

def serialize_table_record_null_value(self, remote_schema, streamed_schema, field, value):
if value is None:
return '\\\\N'
return '\\N'
return value

def serialize_table_record_datetime_value(self, remote_schema, streamed_schema, field, value):
Expand Down Expand Up @@ -521,12 +521,15 @@ def write_table_batch(self, cur, table_batch, metadata):
csv_headers = list(remote_schema['schema']['properties'].keys())
rows_iter = iter(table_batch['records'])

csv_dialect = csv.unix_dialect()
csv_dialect.escapechar = '\\'

def transform():
try:
row = next(rows_iter)

with io.StringIO() as out:
writer = csv.DictWriter(out, csv_headers)
writer = csv.DictWriter(out, csv_headers, dialect=csv_dialect)
writer.writerow(row)
return out.getvalue()
except StopIteration:
Expand Down