Ultimate access to all questions.
The code block below contains an error. It is intended to create a Scala UDF assessPerformanceUDF()
and apply it to the integer column customerSatisfaction
in DataFrame storesDF
. Identify the error.
Code block:
val assessPerformanceUDF = udf((customerSatisfaction: Int) =>
customerSatisfaction match {
case x if x < 20 => 1
case x if x > 80 => 3
case _ => 2
}
)
storesDF.withColumn("result", assessPerformanceUDF(col("customerSatisfaction")))