1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[SQL] Cannot perform Merge: multiple source rows matched in Delta Table

Discussão em 'Outras Linguagens' iniciado por Stack, Outubro 15, 2024 às 18:22.

  1. Stack

    Stack Membro Participativo

    I am facing an issue while performing a MERGE operation on my Delta table. The error message I receive is:


    Cannot perform Merge as multiple source rows matched and attempted to modify the same target row in the Delta table in possibly conflicting ways.

    I have verified that there are no duplicates in the primary key of my target table.

    Data Insertion: Initially, I inserted some input data successfully. However, when I attempt to insert the same data again, I get this error.

    Here’s a simplified version of the SQL code I am using for the MERGE operation:

    MERGE INTO target_table AS t
    USING source_table AS s
    ON t.primary_key = s.primary_key
    WHEN MATCHED THEN
    UPDATE SET t.column1 = s.column1, t.column2 = s.column2
    WHEN NOT MATCHED THEN
    INSERT (primary_key, column1, column2) VALUES (s.primary_key, s.column1, s.column2)


    What could cause multiple source rows to match the same target row, even when there are no duplicates in my primary key?

    How can I preprocess the source data to prevent this issue?

    Continue reading...

Compartilhe esta Página