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

Certified Associate Developer for Apache Spark Exam - Question 82


Which of the following code blocks creates and registers a SQL UDF named "ASSESS_PERFORMANCE" using the Scala function assessPerformance() and applies it to column customerSatisfaction in table stores?

Show Answer
Correct Answer: A

To create and register a SQL UDF named 'ASSESS_PERFORMANCE' using the Scala function assessPerformance(), and apply it to the column customerSatisfaction in the table stores, the code should first register the UDF and then use it correctly within a SQL query context. The code block provided in option A does just that: it registers the UDF with spark.udf.register and then uses the UDF in a SQL query to apply it to the customerSatisfaction column in the stores table. This ensures that the function is correctly applied to the specified column within the context of the SQL query.

Discussion

2 comments
Sign in to comment
Sowwy1Option: A
Apr 5, 2024

A is correct

nadegetiedjoOption: E
Apr 25, 2024

column customerSatisfaction haven't quoted in A so Ithink that the good answer is E

carlosmps
Jun 22, 2024

Option E is incorrect because it attempts to use the SQL UDF name directly in the DataFrame API, which is not supported without using expr or callUDF.