Databricks Certified Associate Developer for Apache Spark — Question 24

Which of the following code blocks returns a new DataFrame from DataFrame storesDF where column storeId is of the type string?

Answer options

Correct answer: B

Explanation

Option B is correct because it properly uses the withColumn method to update the 'storeId' column by casting it to StringType. The other options either have syntax errors, such as missing parentheses or incorrect use of quotes, which would lead to code execution failures.