
Answer-first summary for fast verification
Answer: `external_data.write.format('delta').mode('append').saveAsTable('external_data')`
The correct choice is **C** because using `mode('append')` adds the new data from the external database to the existing data in the Delta table without overwriting anything. Option A might lead to duplicate data and doesn't use Delta's optimized write path. Option B would skip writing any data, which isn't the team's goal. Option D would overwrite all existing data, contrary to the team's requirements.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
A data engineering team needs to read data from an external database and write it to a Databricks Delta table named 'external_data' without overwriting any existing data. Which code snippet should they use?
A
spark.sql('INSERT INTO external_data SELECT * FROM external_data_source')
B
external_data.write.format('delta').mode('ignore').saveAsTable('external_data')
C
external_data.write.format('delta').mode('append').saveAsTable('external_data')
D
external_data.write.format('delta').mode('overwrite').saveAsTable('external_data')
No comments yet.