
Ultimate access to all questions.
Which of the following commands can be used to write data into a Delta table while avoiding the writing of duplicate records?
A
DROP
B
IGNORE
C
MERGE
D
APPEND
E
INSERT
Explanation:
The correct answer is C. MERGE.
WHEN MATCHED THEN UPDATE and WHEN NOT MATCHED THEN INSERT to handle existing and new records appropriately.IGNORE option in some contexts, it's not a standard Delta Lake command for avoiding duplicates during data writes.MERGE INTO target_table AS target
USING source_table AS source
ON target.id = source.id
WHEN MATCHED THEN UPDATE SET *
WHEN NOT MATCHED THEN INSERT *;
MERGE INTO target_table AS target
USING source_table AS source
ON target.id = source.id
WHEN MATCHED THEN UPDATE SET *
WHEN NOT MATCHED THEN INSERT *;
This MERGE statement ensures that if a record with the same ID exists in the target table, it gets updated; otherwise, a new record is inserted, effectively preventing duplicates.