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

The code block shown below should read a JSON at the file path filePath into a DataFrame with the specified schema schema. Choose the response that correctly fills in the numbered blanks within the code block to complete this task.

Code block:

__1__.__2__.__3__(__4__).format("csv").__5__(__6__)

    Correct Answer: E

    To read a JSON file into a DataFrame with a specified schema using Spark, the correct sequence involves first specifying that we are using the Spark session object 'spark', accessing the 'read' method, and then setting the format to 'json'. The 'json' format is specified within the 'format' method. After that, the 'schema' method is called to apply the provided schema, and finally the 'load' method is used to read the file from the specified file path. Therefore, the correct option follows this sequence: spark.read.format('json').schema(schema).load(filePath).

Discussion
nadegetiedjoOption: D

I think that we have an error in the question, the format is CSV so the good answer is D

65bd33e

I agree with you correct is D

SaiPavan10

The question itself is bogus.