Databricks Certified Associate Developer for Apache Spark — Question 68

The code block shown below contains an error. The code block is intended to print the schema of DataFrame storesDF. Identify the error.

Code block:

storesDF.printSchema.getAs[String]

Answer options

Correct answer: D

Explanation

The correct answer is D because printSchema is indeed a method that prints the DataFrame's schema directly, and there's no need for the getAs method. Options A, B, and E incorrectly state that printSchema is non-existent and suggest alternative methods that are not applicable in this context, while option C incorrectly suggests that the entire line should be treated as a string.