Exam Certified Associate Developer for Apache Spark All QuestionsBrowse all questions from this 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?

    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
Sowwy1Option: A

A is correct

nadegetiedjoOption: E

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

carlosmps

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.