Certified Associate Developer for Apache Spark Exam QuestionsBrowse all questions from this exam

Certified Associate Developer for Apache Spark Exam - Question 106


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__

Show Answer
Correct Answer: AC

To create a single-column DataFrame from a Scala list of integers, the Spark APIs should be used in the following way: First, use spark.createDataset to convert the list into a Dataset. The argument should be the Scala list itself, which is appropriately represented as years in the given code block. The resulting Dataset can then be converted to a DataFrame using the toDF method. Therefore, filling in the blanks, the correct response is: spark.createDataset(years).toDF.

Discussion

1 comment
Sign in to comment
Sowwy1Option: C
Apr 2, 2024

I think it's C C. 1. spark 2. createDataset 3. List(years) 4. toDF it says "Scala list"

Sowwy1
Apr 10, 2024

It's part of official databricks questions: Question 44 Which of the following code blocks creates a single-column DataFrame from Scala Listyears which is made up of integers? A. spark.createDataset(years).toDF B. spark.createDataFrame(years, IntegerType) C. spark.createDataset(years) D. spark.DataFrame(years, IntegerType) E. spark.createDataFrame(years) --> and the answer here is A.

carlosmps
Jun 22, 2024

spark.createDataset(years).toDF, to avoid confuse, it's answer C here, and answer A on official databruicks questions. :)

deadbeef38
Jun 22, 2024

I think C is correct, but the result is a DataFrame with a single row whose value is a list of Integers, not a row for each element in the list. None of the other choices makes sense though.