-
Notifications
You must be signed in to change notification settings - Fork 104
fix: Invalid merge when unique_key == merge_update_columns #406
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
Conversation
As follow up of this: #406 (comment) |
Sure, added a couple of tests. |
@artem-garmash it's great to know you're working on athena support for elementary package 💪 🚀 . Is this the only 1 feature which blocks to to publish the solution to main elementary branch ? |
@svdimchenko thx! This was the only issue discovered. As those alert tables work with other connectors in Elementary CLI, I think it should be fixed here. Once this fixed, the elementary cli branch can be finalized. I'm testing now the new branches with the port with proper deployment and hopefully can open new PRs next week. |
@artem-garmash great work - for me we can merge, thanks for the detailed explanation. |
Description
Incremental model may have
unique_key
same asmerge_update_columns
. For example, to skip updates for matched rows and do only inserts and/or deletes. In such cases, the generate merge sql statement is invalid:Another case when the update column list can be empty and generate similar invalid sql is if
merge_exclude_columns
removes all columns.The fix checks the final update list and uses it only if it's not empty, avoid generating incomplete
when matched then update
part of the merge statement.The PR adds 2 tests to cover both cases. As I don't see any ready test to cover
merge_update_columns
usage,TestIncrementalIcebergMergeNoUpdates
just test the original case.TestIcebergMergeExcludeAllColumns
tests usingmerge_exclude_columns
to get empty update column list. And originalTestIcebergMergeExcludeColumns
from dbt-core is added as well as it's used byTestIcebergMergeExcludeAllColumns
.Let me know if the tests should be arranged/named in some other way.
The issue was discovered when trying to port elementary CLI to athena, see https://github.com/artem-garmash/elementary/pull/1/files#r1227587134 for the context.
See full model source: https://github.com/elementary-data/elementary/blob/master/elementary/monitor/dbt_project/models/alerts/alerts.sql
Models used to test
Checklist