If return value of an udf that is passed to transform_values is an AnyRef, then the transformation returns identical new values for each map key (to be more precise, each newly obtained value overrides values for all previously processed keys).
Consider following examples:
or even just this one
After playing with org.apache.spark.sql.catalyst.expressions.TransformValues it looks like something wrong is happening while executing this line:
To be more precise , it's all about functionForEval.eval(inputRow) , because if you do something like this:
You'll see in the logs, something like: