DATABRICKS-DATA-ENGINEER-ASSOCIATE practice question 22 of 25
Which of the following commands can be used to write data into a Delta table while avoiding the writing of duplicate records?
Full set: 177 questionsThe MERGE command is the standard and most effective way to perform "upsert" (update or insert) operations on a Delta table. It allows you to define a matching condition between a source and a target table. By using the WHEN NOT MATCHED THEN INSERT clause, you can specify that only records from the source that do not have a corresponding match in the target table should be inserted. This is the explicit mechanism for writing new data while preventing the creation of duplicate records based on a key or a set of keys.
A. DROP: This command deletes an entire table and its data; it does not write or manage individual records.
B. IGNORE: This is not a primary SQL command for writing data. It can be a clause in other statements but is not the tool for conditional inserts.
D. APPEND: This operation adds all records from the source to the target table, which will create duplicates if the records already exist.
E. INSERT: This command adds new rows to a table without checking for pre-existing records, thus leading to duplicates.
1. Databricks SQL Language Reference
MERGE INTO: "Merges a set of updates
insertions
and deletions based on a source table into a target Delta Lake table." The documentation explicitly details the WHEN NOT MATCHED [BY TARGET] THEN INSERT clause
which is the mechanism for inserting rows that do not exist in the target.
Source: Databricks Documentation > SQL reference > Data manipulation language > MERGE INTO.
2. Databricks Documentation
"Table deletes
updates
and merges": This guide explains how MERGE is used for complex conditional updates. It states
"You can use MERGE to perform complex operations like deduplicating data...". This directly supports using MERGE to avoid duplicates.
Source: Databricks Documentation > Delta Lake guide > Table deletes
updates
and merges.
3. Databricks Documentation
"Best practices: Delta Lake": In the section on simplifying upserts
the documentation recommends MERGE for inserting or updating records. It contrasts this with more complex
multi-step read/write processes
highlighting MERGE as the atomic and efficient solution for this use case
which includes avoiding duplicate insertions.
Source: Databricks Documentation > Delta Lake guide > Best practices > Upsert into a table using merge.
Keep practicing
Take the free DATABRICKS-DATA-ENGINEER-ASSOCIATE practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other DATABRICKS-DATA-ENGINEER-ASSOCIATE practice questions
- Question 1In which of the following scenarios should a data engineer use the MERGE INTO command ins…
- Question 2Which of the following data workloads will utilize a Gold table as its source?
- Question 3A data engineer has developed a data pipeline to ingest data from a JSON source using Aut…
- Question 4Which two components function in the DB platform architecture’s control plane? (Choose tw…
- Question 5Which of the following code blocks will remove the rows where the value in column age is …
- Question 7Which of the following statements regarding the relationship between Silver tables and Br…
