Databricks Certified Associate Developer for Apache Spark — Question 142
In what order should the below lines of code be run in order to read a parquet at the file path filePath into a DataFrame?
Lines of code:
1. storesDF
2. .load(filePath, source = "parquet")
3. .read \
4. spark \
5. .read() \
6. .parquet(filePath)
Answer options
- A. 1, 5, 2
- B. 4, 5, 2
- C. 4, 3, 6
- D. 4, 5, 6
- E. 4, 3, 2
Correct answer: C
Explanation
The correct sequence is 4, 3, 6 because you first need to initiate the Spark session with 'spark', then use '.read' to prepare for reading, and finally call '.parquet(filePath)' to read the parquet file into a DataFrame. The other options either miss a step or include incorrect methods that do not properly read the parquet file.