Databricks Certified Associate Developer for Apache Spark — Question 213

The code block shown below should return a new DataFrame from DataFrame storesDF where column storeId is of the type string. Choose the response that correctly fills in the numbered blanks within the code block to complete this task.

Code block:

storesDF.__1__("storeId", __2__("storeId").__3__(__4__)

Answer options

Correct answer: A

Explanation

Option A is correct because it properly uses the withColumn method to create a new column with the specified transformations. The other options either misplace the function calls or do not utilize the correct order of operations, such as using 'cast' and 'col' incorrectly.