Skip to content

Conversation

@jorritsandbrink
Copy link
Collaborator

@jorritsandbrink jorritsandbrink commented Aug 19, 2024

Description

  • enables the insert-delete-reinsert pattern (see 55850de) for scd2
  • drops unique constraint on _dlt_id in root tables (except when users bring their own hash)

Related Issues

Fixes #1683

@jorritsandbrink jorritsandbrink linked an issue Aug 19, 2024 that may be closed by this pull request
@netlify
Copy link

netlify bot commented Aug 19, 2024

Deploy Preview for dlt-hub-docs canceled.

Name Link
🔨 Latest commit 3d6e4fc
🔍 Latest deploy log https://app.netlify.com/sites/dlt-hub-docs/deploys/66c34be2e7bf88000885413f

SELECT {col_str}, {boundary_ts} AS {from_}, {active_record_literal} AS {to}
FROM {staging_root_table_name} AS s
WHERE {hash_} NOT IN (SELECT {hash_} FROM {root_table_name});
WHERE {hash_} NOT IN (SELECT {hash_} FROM {root_table_name} WHERE {is_active_clause});
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change enables reinsertion of a record if there is no active version of that record in the destination table.

One possible issue: users might have a UNIQUE constraint on the _dlt_id column in their existing scd2 tables. This will cause a uniqueness error. Those users would have to drop those constraints manually when upgrading to a newer version of dlt.

@jorritsandbrink jorritsandbrink marked this pull request as ready for review August 19, 2024 13:43
Copy link
Collaborator

@rudolfix rudolfix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! also thanks for the docs update

@rudolfix rudolfix merged commit 843b658 into devel Aug 21, 2024
@rudolfix rudolfix deleted the fix/1683-scd2-record-reinsertion branch August 21, 2024 08:24
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.

scd2 merge strategy does not reinsert records

3 participants