Databricks Certified Associate Developer for Apache Spark — Question 70

The code block shown below should extract the integer value for column sqft from the first row of DataFrame storesDF. Choose the response that correctly fills in the numbered blanks within the code block to complete this task.

Code block:

__1__.__2__.__3__[Int](__4__)

Answer options

Correct answer: D

Explanation

The correct answer is D because it uses the method first() to access the first row and getAs() to retrieve the value from the column 'sqft' as an integer. Option A incorrectly uses getAs() with parentheses, and option B omits the necessary parentheses for first(). Option C incorrectly uses col() which is not needed in this context.