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

Certified Associate Developer for Apache Spark Exam - Question 104


The code block shown below contains an error. The code block is intended to create and register a SQL UDF named “ASSESS_PERFORMANCE” using the Scala function assessPerformance() and apply it to column customerSatisfaction in the table stores. Identify the error.

Code block:

spark.udf.register(“ASSESS_PERFORMANCE”, assessPerforance)

spark.sql(“SELECT customerSatisfaction, assessPerformance(customerSatisfaction) AS result FROM stores”)

Show Answer
Correct Answer: DE

The error in the code block is that the wrong SQL function is used to compute the column result. The registered UDF name 'ASSESS_PERFORMANCE' should be used in the SQL statement instead of the Scala function name 'assessPerformance'. Therefore, the SQL query should be 'SELECT customerSatisfaction, ASSESS_PERFORMANCE(customerSatisfaction) AS result FROM stores'.

Discussion

6 comments
Sign in to comment
zozoshankyOption: D
Jul 30, 2023

D is the answer

Ram459Option: D
Aug 17, 2023

yup D is correct

thanabOption: D
Sep 7, 2023

D The error in the code block is D. The wrong SQL function is used to compute column result - it should be ASSESS_PERFORMANCE instead of assessPerformance.

veli4koOption: D
Sep 29, 2023

D is correct

SaiPavan10Option: C
Apr 4, 2024

D is the right choice.

cd6a625Option: D
Jul 8, 2024

D is the correct answer