Databricks Certified Associate Developer for Apache Spark — Question 122

Which of the following code blocks reads a CSV at the file path filePath into a Data Frame with the specified schema schema?

Answer options

Correct answer: C

Explanation

The correct answer, C, accurately specifies the schema using the method chain 'schema(schema)' before reading the CSV from filePath. Options A and B do not utilize the schema method correctly, while D uses a string instead of a variable for the schema, and E incorrectly places the schema method after another read method instead of correctly chaining it.