Skip to content

[Bug] Snapshot dbt_scd_id is not computed according to documentation in check strategy #1436

@spyrosviz

Description

@spyrosviz

Is this a new bug?

  • I believe this is a new bug
  • I have searched the existing issues, and I could not find an existing issue for this bug

Which packages are affected?

  • dbt-adapters
  • dbt-tests-adapter
  • dbt-athena
  • dbt-athena-community
  • dbt-bigquery
  • dbt-postgres
  • dbt-redshift
  • dbt-snowflake
  • dbt-spark

Current Behavior

The dbt_scd_id is computed as
md5(
coalesce(cast(unique_key1 as string), '') || '|' ||
coalesce(cast(unique_key2 as string), '') || '|' ||
coalesce(cast(updated_at as string), '')
)
both in timestamp and check strategy.

Expected Behavior

When configured strategy is check according to the documentation it should be the hash of unique keys and columns provided in check_cols.

Steps To Reproduce

  1. Create a snapshot that tracks a source table.
  2. Add in snapshot configuration the unique_key, set strategy as 'check' and add in check_cols the columns you want to track for updates.
  3. Run the snapshot
  4. Select the snapshot dbt_scd_id and add in select a custom scd_id column as
    md5(
    coalesce(cast(unique_key1 as string), '') || '|' ||
    coalesce(cast(unique_key2 as string), '') || '|' ||
    coalesce(cast(check_col1 as string), '') || '|' ||
    coalesce(cast(check_col2 as string), '')
    )
    which is how the dbt_scd_id is supposed to be computed in check strategy.
  5. If you now select again and select a custom scd_id as
    md5(
    coalesce(cast(unique_key1 as string), '') || '|' ||
    coalesce(cast(unique_key2 as string), '') || '|' ||
    coalesce(cast(updated_at as string), '')
    )
    the dbt_scd_id matches with that one

Relevant log output

Environment

- OS: Ubuntu 22.04 (Databricks Runtime 15.4 LTS job cluster)
- Python: 3.11.11
- dbt-core: 1.10.13
- dbt-databricks: 1.9.1

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    triage:productIn Product's queuetype:bugSomething isn't working as documented

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions