Databricks Certified Associate Developer for Apache Spark — Question 51
In what order should the below lines of code be run in order to read a JSON file at the file path filePath into a DataFrame with the specified schema schema?
Lines of code:
1. .json(filePath, schema = schema)
2. .storesDF
3. .spark \
4. .read() \
5. .read \
6. .json(filePath, format = schema)
Answer options
- A. 3, 5, 6
- B. 2, 4, 1
- C. 3, 5, 1
- D. 2, 5, 1
- E. 3, 4, 1
Correct answer: C
Explanation
The correct sequence is C: first, you initiate the Spark session with .spark, then you call .read to access the DataFrame reader, and finally, you use .json(filePath, schema = schema) to load the JSON file with the defined schema. The other options either miss the correct method calls or include incorrect parameters.