Databricks Certified Associate Developer for Apache Spark — Question 34
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")
Answer options
- A. 1. udf 2. register 3. "ASSESS_PERFORMANCE" 4. assessPerformance 5. ASSESS_PERFORMANCE
- B. 1. udf 2. register 3. assessPerformance 4. "ASSESS_PERFORMANCE" 5. "ASSESS_PERFORMANCE"
- C. 1. udf 2. register 3."ASSESS_PERFORMANCE" 4. assessPerformance 5. "ASSESS_PERFORMANCE"
- D. 1. register 2. udf 3. "ASSESS_PERFORMANCE" 4. assessPerformance 5. "ASSESS_PERFORMANCE"
- E. 1. udf 2. register 3. ASSESS_PERFORMANCE 4. assessPerformance 5. ASSESS_PERFORMANCE
Correct answer: A
Explanation
Option A is correct because it properly uses 'udf' to create a user-defined function, 'register' to register it with the name 'ASSESS_PERFORMANCE', and applies the function correctly in the SQL statement. The other options either misuse quotes or incorrectly order the function and registration steps, making them invalid for the intended operation.