Databricks Certified Associate Developer for Apache Spark — Question 44
The code block shown below contains an error. The code block intended to read a parquet at the file path filePath into a DataFrame. Identify the error.
Code block:
spark.read.load(filePath, source – "parquet")
Answer options
- A. There is no source parameter to the load() operation – the schema parameter should be used instead.
- B. There is no load() operation – it should be parquet() instead.
- C. The spark.read operation should be followed by parentheses to return a DataFrameReader object.
- D. The filePath argument to the load() operation should be quoted.
- E. There is no source parameter to the load() operation – it can be removed.
Correct answer: E
Explanation
The correct answer is E because the load() method does not require the source parameter; it can be omitted entirely. Options A and B are incorrect as they suggest incorrect usage of parameters or method names. Option C is wrong because the spark.read operation does not require parentheses to function properly. Option D misinterprets the need for quoting the filePath argument, which is not necessary.