Databricks Certified Associate Developer for Apache Spark — Question 154

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

Answer options

Correct answer: B

Explanation

Option B is correct because it correctly uses the method chaining to set the mode to 'overwrite' and then specifies the file path to save as text. Options A and E have incorrect method placements or syntax for writing to a file. Option C incorrectly uses 'path' instead of 'text', and Option D misuses the 'option' method, which is not applicable in this context.