Databricks Certified Associate Developer for Apache Spark — Question 215
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
Answer options
- A. There is no printSchema member of DataFrame – schema and the print() function should be used instead.
- B. The entire line needs to be a string – it should be wrapped by str().
- C. There is no printSchema member of DataFrame – the getSchema() operation should be used instead.
- D. There is no printSchema member of DataFrame – the schema() operation should be used instead.
- E. The printSchema member of DataFrame is an operation and needs to be followed by parentheses.
Correct answer: E
Explanation
The correct answer is E because the printSchema method must be called with parentheses to execute it properly. Options A, C, and D are incorrect as they misidentify the nature of the printSchema method. Option B is also incorrect because wrapping the line in str() is not relevant to the issue at hand.