QuestionQ22

VerifiedDeveloping Apache Spark™ DataFrame/DataSet API Applications

The code block below must create a single-column DataFrame from the Scala list years, which consists of integers. Choose the response that correctly fills the numbered blanks in the code block to complete this task.

Code block:

__1__.__2__(__3__).__4__

Explanation

SparkSession createDataset creates a Dataset from a Scala sequence, and Dataset.toDF() converts that typed Dataset into a DataFrame. Creating a Dataset from List(years) and invoking toDF therefore produces a one-column DataFrame whose value is the integer list. IntegerType is a Spark SQL data-type descriptor, not the DataFrame conversion method required by this expression.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!