Let's say I want to make an spark UDF to reverse the ordering of an array of structs. The concrete type of the struct should not matter, so I tried:
val reverseUDF = udf((s:Seq[_]) => s.reverse)
But this gives
java.lang.UnsupportedOperationException: Schema for type Any is not supported
I also tried to use a generic method and force type generic type parameter to be a subtype of Product
:
def reverse[T <: Product](s:Seq[T]) = {
s.reverse
}
val reverseUDF = udf(reverse _)
This gives:
scala.MatchError: Nothing (of class scala.reflect.internal.Types$TypeRef$$anon$6)
So is this even possible?