Skip to content

snapshot with unique key longer than 30 chars fails on duplicate #117

@dubravcik

Description

@dubravcik

Hi, I have a snapshot with unique_key on hash and I am getting duplicate error on internal dbt_scd_id in merge phase.

I checked the dbt code and problem is, it converts the id_hash to varchar. SQL Server uses by default 30 (!?wt.f!?) chars if you state varchar without a length.

CONVERT(VARCHAR(32), HashBytes(''MD5'', 
        coalesce(CONVERT(>>>>varchar<<<<, [id_hash], 121), '''')  + ''|'' +     
        coalesce(CONVERT(>>>>varchar<<<<, CONVERT(DATETIME2, ''2021-02-22 19:33:59.020000''), 121), '''') 
    ), 2)

I would probably change it to varchar(max) as it is changed to varchar(32) at the end anyway.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions