Databricks Certified Associate Developer for Apache Spark — Question 43

Which of the following code blocks writes DataFrame storesDF to file path filePath as JSON?

Answer options

Correct answer: B

Explanation

The correct answer, B, directly uses the .json() method to write the DataFrame as JSON to the specified file path. Option A incorrectly uses the .option() method, which does not properly specify the JSON format for writing. Options C and D do not specify the JSON format at all, and option E is syntactically correct but less direct than option B.