Exam Certified Associate Developer for Apache Spark All QuestionsBrowse all questions from this exam
Question 164

The code block shown below contains an error. The code block is intended to read JSON at the file path filePath into a DataFrame with the specified schema schema. Identify the error.

Code block:

spark.read.schema("schema").format("json").load(filePath)

    Correct Answer: A

    The schema operation from read takes a schema object rather than a string — the argument should be schema. This means that instead of using a string when specifying the schema, the correct approach is to pass the schema object directly.

Discussion
Sowwy1Option: A

A. The schema operation from read takes a schema object rather than a string — the argument should be schema.