Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ers81239 committed Apr 22, 2021
1 parent 4e18d4f commit 30d2273
Showing 1 changed file with 5 additions and 2 deletions.
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

0 comments on commit 30d2273

Please sign in to comment.