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

Exam Certified Associate Developer for Apache Spark All Questions

View all questions & answers for the Certified Associate Developer for Apache Spark exam

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

The code block shown below contains an error. The code block is intended to create the Scala UDF assessPerformanceUDF() and apply it to the integer column customers1t1sfaction in Data Frame storesDF. Identify the error.

Code block:

  • A. The input type of customerSatisfaction is not specified in the udf() operation.
  • B. The return type of assessPerformanceUDF() must be specified.
  • C. The withColumn() operation is not appropriate here - UDFs should be applied by iterating over rows instead.
  • D. The assessPerformanceUDF() must first be defined as a Scala function and then converted to a UDF.
  • E. UDFs can only be applied via SQL and not through the Data Frame API.
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
beds2898
3 months, 2 weeks ago
these dumps is for python or scala?
upvoted 1 times
...
carlosmps
5 months, 1 week ago
Ans. B val assessPerformanceUDF = udf((customerSatisfaction: Int) => { customerSatisfaction match { case x if x < 20 => 1 case x if x > 80 => 3 case _ => 2 } }, IntegerType) // Apply the UDF to the DataFrame val resultDF = storesDF.withColumn("result", assessPerformanceUDF(col("customerSatisfaction"))) resultDF.show()
upvoted 1 times
deadbeef38
5 months ago
But you also gave a type for the customerSatisfaction input parameter. I think the answer is A
upvoted 2 times
...
...
Sowwy1
7 months, 3 weeks ago
I think it's B
upvoted 1 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 ...