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

Certified Associate Developer for Apache Spark 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")

Show Answer
Correct Answer: A

Discussion

2 comments
Sign in to comment
4be8126Option: A
May 1, 2023

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
Mar 7, 2024

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