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

Issue-5: Add support for creating change streams via config option for primary key #10

Merged
merged 5 commits into from
Mar 28, 2023

Conversation

nicoweidner
Copy link
Contributor

@nicoweidner nicoweidner commented Mar 27, 2023

Resolves #5
Resolves #6

Forgot about this: Maybe the configured primary key also needs to be considered in the change detection logic (

). Will investigate

@@ -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) -%}
Copy link
Contributor Author

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() %}
Copy link
Contributor Author

@nicoweidner nicoweidner Mar 27, 2023

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 ?

Copy link
Contributor

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.

@rmetzger
Copy link
Contributor

Thanks a lot for this PR. This is a very good improvement!

I validated the change locally, and it works as expected.

@nicoweidner nicoweidner merged commit 0b88016 into decodableco:main Mar 28, 2023
@nicoweidner nicoweidner deleted the changestream_support branch March 28, 2023 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Table sink doesn't support consuming update and delete changes Can't generate change stream via dbt
2 participants