SSC-FDM-RS0005

Duplicates not allowed in source table

Description

In Redshift, the MERGE statement throws an error when the source table has duplicate values. Snowflake doesn't throw the error and instead, it allows the query execution. The FDM warns about this behavior, that it could change the result in the converted MERGE.

Code Example

Input Code:

IN -> Redshift_01.sql
MERGE INTO target USING source ON target.id = source.id
WHEN MATCHED THEN DELETE
WHEN NOT MATCHED THEN INSERT VALUES (source.id, source.name);

Output Code:

OUT -> Redshift_01.sql
--** SSC-FDM-RS0005 - REDSHIFT MERGE STATEMENT DOESN'T ALLOW DUPLICATES IN THE SOURCE TABLE. SNOWFLAKE BEHAVIOR MAY DIFFER IF THERE ARE DUPLICATE VALUES. **
MERGE INTO target USING source ON target.id = source.id
WHEN MATCHED THEN DELETE
WHEN NOT MATCHED THEN INSERT VALUES (source.id, source.name);

Recommendations

Last updated