Databricks Certified Associate Developer for Apache Spark — Question 91
The code block shown below should read a CSV 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. schema 4. schema 5. load 6. filePath
- C. 1. spark 2. read 3. format 4. "json" 5. load 6. filePath
- D. 1. spark 2. read() 3. json 4. filePath 5. format 6. schema
- E. 1. spark 2. read 3. schema 4. schema 5. load 6. filePath
Correct answer: E
Explanation
The correct answer is E because it properly utilizes the Spark DataFrameReader's method to read a file with a specified schema. The other options either use incorrect methods or parameters that do not correspond to reading a CSV file into a DataFrame.