QuestionQ292

VerifiedDeveloping Apache Spark™ DataFrame/DataSet API Applications

The code block below includes an error. It is intended to create the Scala UDF assessPerformanceUDF() and apply it to the integer column customers1t1sfaction in Data Frame storesDF. Identify the error.

Code block:

Question Image

Explanation

A Scala Spark UDF infers its input and output SQL types from the Scala closure’s signature. The closure parameter must therefore declare its type, for example (customerSatisfaction: Int) => .... The match branches already infer an Int result, and a UDF may validly be applied through the DataFrame API with withColumn.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!