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

The code block shown below should create and register a SQL UDF named "ASSESS_PERFORMANCE" using the Python function assessPerformance() and apply it to column customerSatisfaction in table stores. Choose the response that correctly fills in the numbered blanks within the code block to complete this task.

Code block:

spark._1_._2_(_3_, _4_)

spark.sql("SELECT customerSatisfaction, _5_(customerSatisfaction) AS result FROM stores")

    Correct Answer: A

Discussion
4be8126Option: A

Answer: A Explanation: udf: create a user-defined function (UDF) in PySpark register: register the UDF with Spark so it can be used in SQL queries "ASSESS_PERFORMANCE": name the UDF "ASSESS_PERFORMANCE" assessPerformance: specify the Python function to use for the UDF ASSESS_PERFORMANCE: use the registered UDF in the SQL query to apply the assessPerformance() function to the customerSatisfaction column.

azurearchOption: A

def assessperformance(): return 'Good' spark.udf.register("assessperformance",assessperformance) df = spark.sql("SELECT assessperformance()") df.show() A