SpinTheMic
Pro

Explain it in 60 seconds

MERGE and nondeterministic matches

Data Engineering · Snowflake · Intermediate

How does MERGE behave in Snowflake when multiple source rows match the same target row?

What a strong answer covers

Your AI report card counts how many of these ideas you cover.

  • MERGE combines insert, update and delete in one atomic statement.
  • If several source rows match one target row, the result is nondeterministic.
  • By default ERROR_ON_NONDETERMINISTIC_MERGE is TRUE, so Snowflake raises an error.
  • Fix it by deduplicating the source first, for example with QUALIFY ROW_NUMBER() = 1.
  • Filter the target with a date range to keep MERGE from scanning the whole table.
Practise this topic

Start without signing up. Sign in free to get an AI report card on your answer.

See all topics