Databricks Certified Associate Developer for Apache Spark — Question 126
The code block shown below should read a JSON at the file path filePath into a DataFrame with the specified schema schema. Choose the response that correctly fills in the numbered blanks within the code block to complete this task.
Code block:
__1__.__2__.__3__(__4__).format("csv").__5__(__6__)
Answer options
- A. 1. spark 2. read() 3. schema 4. schema 5. json 6. filePath
- B. 1. spark 2. read() 3. json 4. filePath 5. format 6. schema
- C. 1. spark 2. read() 3. schema 4. schema 5. load 6. filePath
- D. 1. spark 2. read 3. schema 4. schema 5. load 6. filePath
- E. 1. spark 2. read 3. format 4. "json" 5. load 6. filePath
Correct answer: D
Explanation
The correct answer is D because it accurately calls the read method on the spark object, specifies the schema with the correct syntax, and uses the load method to read the file at filePath. Options A and C incorrectly use the 'read()' method and do not align with the expected method format, while B and E misplace the order of parameters and methods needed for this operation.