Skip to content

Commit

Permalink
fix column order mismatch using explicit copy into selects
Browse files Browse the repository at this point in the history
  • Loading branch information
pnadolny13 committed Sep 12, 2023
1 parent 3ab7f03 commit fafa15a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion target_snowflake/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,10 +349,11 @@ def _get_merge_from_stage_statement(
def _get_copy_statement(self, full_table_name, schema, sync_id, file_format):
"""Get Snowflake COPY statement."""
formatter = SnowflakeIdentifierPreparer(SnowflakeDialect())
formatted_properties = ", ".join([formatter.format_collation(col) for col in schema["properties"].keys()])
column_selections = self._get_column_selections(schema, formatter)
return (
text(
f"copy into {full_table_name} from "
f"copy into {full_table_name} ({formatted_properties}) from "
+ f"(select {', '.join(column_selections)} from "
+ f"'@~/target-snowflake/{sync_id}')"
+ f"file_format = (format_name='{file_format}')"
Expand Down

0 comments on commit fafa15a

Please sign in to comment.