From 30d2273e97c50ee29dd796f0b5a2f004c8705a14 Mon Sep 17 00:00:00 2001 From: edward Date: Thu, 22 Apr 2021 17:15:23 -0400 Subject: [PATCH] Fixes datamill-co/target-snowflake#21 --- target_snowflake/snowflake.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/target_snowflake/snowflake.py b/target_snowflake/snowflake.py index 93250e6..31a0fa6 100644 --- a/target_snowflake/snowflake.py +++ b/target_snowflake/snowflake.py @@ -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): @@ -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: