CERTIFIED-DATA-ENGINEER-PROFESSIONAL · Question #27
A junior data engineer on your team has implemented the following code block. The view new_events contains a batch of records with the same schema as the events Delta table. The event_id field…
The correct answer is B. They are ignored. The code block (not fully shown) uses a MERGE statement that only includes a WHEN NOT MATCHED THEN INSERT clause - there is no WHEN MATCHED clause. In Delta Lake MERGE operations, if no WHEN MATCHED clause is defined, source records that find a match in the target table are…
Question
A junior data engineer on your team has implemented the following code block. The view new_events contains a batch of records with the same schema as the events Delta table. The event_id field serves as a unique key for this table. When this query is executed, what will happen with new records that have the same event_id as an existing record?
Options
- AThey are merged.
- BThey are ignored.
- CThey are updated.
- DThey are inserted.
- EThey are deleted.
How the community answered
(56 responses)- B95% (53)
- C2% (1)
- E4% (2)
Explanation
The code block (not fully shown) uses a MERGE statement that only includes a WHEN NOT MATCHED THEN INSERT clause - there is no WHEN MATCHED clause. In Delta Lake MERGE operations, if no WHEN MATCHED clause is defined, source records that find a match in the target table are silently skipped (ignored). They are neither updated, deleted, nor inserted again. Only records in the source that do NOT have a matching key in the target are inserted. This is a common pattern for idempotent 'insert-if-not-exists' logic, and the result for duplicates is that they are ignored.
Topics
Community Discussion
No community discussion yet for this question.