QuestionQ290

VerifiedDeveloping Apache Spark™ DataFrame/DataSet API Applications

The code block below has an error. It is intended to read the CSV at the file path filePath into a DataFrame using the specified schema schema. Identify the error.

spark.read.schema("schema").csv(filePath)  
Explanation

DataFrameReader.schema() must receive the intended schema value. Passing "schema" supplies a string literal rather than the schema variable, so the reader does not use the specified schema object. DataFrameReader.csv() is a valid method, and spark.read already returns a DataFrameReader.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!