Databricks Certified Associate Developer for Apache Spark — Question 212

Which of the following code blocks writes DataFrame storesDF to file path filePath as parquet overwriting any existing files in that location?

Answer options

Correct answer: C

Explanation

The correct answer, C, properly uses the DataFrameWriter to set the mode to 'overwrite' before specifying the parquet format for writing to the file path. Option A incorrectly attempts to set the mode as a parameter of the write method, while D uses the wrong method to set the overwrite option. Option B is also incorrect because it attempts to set the mode after calling 'write' instead of using the correct chaining method. Option E does not specify the format as parquet before writing.