-
Notifications
You must be signed in to change notification settings - Fork 3
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
Issue-5: Add support for creating change streams via config option for primary key #10
Issue-5: Add support for creating change streams via config option for primary key #10
Conversation
@@ -14,7 +14,8 @@ | |||
* limitations under the License. | |||
*/ | |||
|
|||
{% macro decodable__create_table_as(temporary, relation, sql, primary_key=none) -%} | |||
{% macro decodable__create_table_as(temporary, relation, sql) -%} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the primary_key
parameter as it was unused, and I think there is no way to set it automatically
@@ -29,7 +29,8 @@ | |||
{% set should_create = {'value': false} %} | |||
{% if existing_relation is not none %} | |||
{% set watermark = config.get('watermark') %} | |||
{% if adapter.has_changed(sql, target_relation, watermark) or should_full_refresh() %} | |||
{% set primary_key = config.get('primary_key') %} | |||
{% if adapter.has_changed(sql, target_relation, watermark, primary_key) or should_full_refresh() %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is the right thing to do to consider the primary key field in this comparison (we also consider watermark, for example). However, I am a bit uncertain about the behavior in general: If changes to the target stream are detected, it is simply deleted and recreated. Is that intended behavior @gunnarmorling @rmetzger ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recreation of changed streams is the desired behavior. I will document this in the README if it isn't there already.
ec06bfa
to
5ec51be
Compare
Thanks a lot for this PR. This is a very good improvement! I validated the change locally, and it works as expected. |
Resolves #5
Resolves #6
Forgot about this: Maybe the configured primary key also needs to be considered in the change detection logic (
dbt-decodable/dbt/adapters/decodable/impl.py
Line 380 in c6d344f