Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.

Unlimited Access

Get Unlimited Contributor Access to the all ExamTopics Exams!
Take advantage of PDF Files for 1000+ Exams along with community discussions and pass IT Certification Exams Easily.

Exam Certified Associate Developer for Apache Spark topic 1 question 85 discussion

The code block shown below contains an error. The code block intended to create a single-column DataFrame from Scala List years which is made up of integers. Identify the error.

Code block:

spark.createDataset(years)

  • A. The years list should be wrapped in another list like List(years) to make clear that it is a column rather than a row.
  • B. The data type is not specified – the second argument to createDataset should be IntegerType.
  • C. There is no operation createDataset – the createDataFrame operation should be used instead.
  • D. The result of the above is a Dataset rather than a DataFrame – the toDF operation must be called at the end.
  • E. The column name must be specified as the second argument to createDataset.
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
Sowwy1
1 month, 1 week ago
Official Databricks tests (where answer is A) 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)
upvoted 1 times
Sowwy1
1 month, 1 week ago
Hence I'll go for D.
upvoted 1 times
...
...
tangerine141
2 months, 3 weeks ago
Selected Answer: C
C. There is no operation createDataset – the createDataFrame operation should be used instead. The correct method to create a DataFrame in Spark using Scala is createDataFrame, not createDataset. The correct syntax would be: scala Copy code val df = spark.createDataFrame(years.map(Tuple1.apply)).toDF("columnName") This assumes that years is a List of integers, and the resulting DataFrame will have a single column named "columnName".
upvoted 1 times
...
zozoshanky
9 months, 3 weeks ago
C is the answer
upvoted 3 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...