LeetQuiz Logo
Privacy Policy•contact@leetquiz.com
© 2025 LeetQuiz All rights reserved.
Databricks Certified Associate Developer for Apache Spark

Databricks Certified Associate Developer for Apache Spark

Get started today

Ultimate access to all questions.


Which of the following code blocks correctly reads a CSV file from the specified path filePath into a DataFrame using the given schema schema?

Exam-Like




Explanation:

The correct method to read a CSV file with a specified schema in Apache Spark is to use spark.read.schema(schema).csv(filePath). This is because the schema method expects a StructType object, not a string. Option C correctly uses the schema method with a StructType object and does not use parentheses around spark.read, which is the correct syntax in both Scala and Python. Option E also correctly uses the schema method with a StructType object but includes parentheses around spark.read, which is valid in Scala but not in Python. Since the question does not specify the language and provides 5 options, both C and E are considered correct for Scala, but only C is correct for Python. Given the context of the Databricks certification, which covers both languages, both options are provided as correct answers.

Powered ByGPT-5