Skip to content
This repository was archived by the owner on Mar 13, 2020. It is now read-only.

Commit ba7c8c5

Browse files
committed
[SP-337] Move method to batch data loader
1 parent 4117998 commit ba7c8c5

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

rdl/BatchDataLoader.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ def load_batch(self, batch_key_tracker):
6161
batch_key_tracker.has_more_data = False
6262
return
6363

64+
# replacing unicode null characters because postgres doesn't support null characters in text fields
65+
# https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.replace.html
66+
data_frame = data_frame.replace(regex=r"\x00", value="")
67+
6468
data_frame = self.attach_column_transformers(data_frame)
6569
self.write_data_frame_to_table(data_frame)
6670
batch_tracker.load_completed_successfully()
@@ -122,7 +126,8 @@ def write_data_frame_to_table(self, data_frame):
122126
f"null '\\N', "
123127
f"FORCE_NULL ({column_list}))"
124128
)
125-
self.logger.debug(f"Writing to table using command '{sql}'")
129+
130+
self.logger.info(f"Writing to table using command '{sql}'")
126131

127132
curs.copy_expert(sql=sql, file=data)
128133

rdl/data_sources/AWSLambdaDataSource.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,7 @@ def __get_table_data(
141141
return result["ColumnNames"], data
142142

143143
def __get_data_frame(self, data: [[]], column_names: []):
144-
return pandas.DataFrame(data=data, columns=column_names).replace(
145-
regex=r"\x00", value=""
146-
)
144+
return pandas.DataFrame(data=data, columns=column_names)
147145

148146
def __invoke_lambda(self, pay_load):
149147
self.logger.debug("\nRequest being sent to Lambda:")

0 commit comments

Comments
 (0)