
Ultimate access to all questions.
The code block shown below contains an error. The code block is intended to create the Scala UDF assessPerformanceUDF() and apply it to the integer column customerSatisfaction in DataFrame storesDF. Identify the error.
Code block:
val assessPerformanceUDF = udf( (score: Int) => {
if (score > 8) "High"
else if (score > 5) "Medium"
else "Low"
})
storesDF.withColumn("performance", assessPerformanceUDF(customers1t1sfaction))
val assessPerformanceUDF = udf( (score: Int) => {
if (score > 8) "High"
else if (score > 5) "Medium"
else "Low"
})
storesDF.withColumn("performance", assessPerformanceUDF(customers1t1sfaction))

A
The input type of customerSatisfaction is not specified in the udf() operation.
B
The return type of assessPerformanceUDF() must be specified.
C
The withColumn() operation is not appropriate here - UDFs should be applied by iterating over rows instead.
D
The assessPerformanceUDF() must first be defined as a Scala function and then converted to a UDF.
E
UDFs can only be applied via SQL and not through the Data Frame API.