
Answer-first summary for fast verification
Answer: There is no source parameter to the load() operation – it can be removed.
The error in the code block is due to the incorrect use of the `source` parameter in the `load()` method, which is not a valid parameter. The correct approach to read a parquet file in Apache Spark is to either use the `format()` method followed by `load()` or directly use the `parquet()` method. The `load()` method itself does not accept a `source` parameter. Therefore, the `source` parameter should be removed, and the correct method to read a parquet file should be employed. Options A and B suggest incorrect alternatives, while option C is irrelevant to the error in question. Option D is incorrect because the `filePath` does not necessarily need to be quoted unless it's a string literal. Option E correctly identifies that the `source` parameter should be removed.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
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.
spark.read.load(filePath, source – "parquet")
spark.read.load(filePath, source – "parquet")
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.
No comments yet.