Databricks Certified Associate Developer for Apache Spark — Question 119

The code block shown below should create a single-column DataFrame from Scala list years which is made up of integers. Choose the response that correctly fills in the numbered blanks within the code block to complete this task.

Code block:

__1__.__2__(__3__).__4__

Answer options

Correct answer: A

Explanation

Option A is correct because it uses the appropriate method createDataFrame to create a DataFrame from the Scala list years and specifies the type as IntegerType. Option B incorrectly uses createDataset instead of createDataFrame. Option C uses List(years) instead of years directly, and also employs toDF which is not suitable for this context. Option D is incorrect because it also uses List(years) instead of years, despite having the correct method and type.