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

fix: duplicate record test #47

Merged
merged 6 commits into from
Jun 14, 2023
Merged
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion target_snowflake/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,11 +270,13 @@ def _get_merge_from_stage_statement(
not_matched_insert_values = ", ".join(
[f's.{col}' for col in formatted_properties]
)
dedup_cols = ", ".join([key for key in formatted_key_properties])
dedup = f"QUALIFY ROW_NUMBER() OVER (PARTITION BY {dedup_cols} ORDER BY SEQ8() DESC) = 1"
return (
text(
f"merge into {full_table_name} d using "
+ f"(select {', '.join(column_selections)} from '@~/target-snowflake/{sync_id}'"
+ f"(file_format => {file_format})) s "
+ f"(file_format => {file_format}) {dedup}) s "
+ f"on {join_expr} "
+ f"when matched then update set {matched_clause} "
+ f"when not matched then insert ({not_matched_insert_cols}) "
Expand Down
3 changes: 1 addition & 2 deletions tests/test_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,7 @@ def validate(self) -> None:
SnowflakeTargetCamelcaseComplexSchema,
SnowflakeTargetCamelcaseTest,
TargetCliPrintsTest,
# TODO: bug https://github.com/MeltanoLabs/target-snowflake/issues/41
# SnowflakeTargetDuplicateRecords,
SnowflakeTargetDuplicateRecords,
SnowflakeTargetEncodedStringData,
SnowflakeTargetInvalidSchemaTest,
# Not available in the SDK yet
Expand Down