Github user viirya commented on a diff in the pull request:
https://github.com/apache/spark/pull/20797#discussion_r173682156
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/objects/objects.scala
---
@@ -266,8 +266,26 @@ case class Invoke(
override def nullable: Boolean = targetObject.nullable || needNullCheck
|| returnNullable
override def children: Seq[Expression] = targetObject +: arguments
- override def eval(input: InternalRow): Any =
- throw new UnsupportedOperationException("Only code-generated
evaluation is supported.")
+ override def eval(input: InternalRow): Any = {
+ val obj = targetObject.eval(input)
+ val args = arguments.map(e => e.eval(input).asInstanceOf[Object])
+ val argClasses =
CallMethodViaReflection.expressionJavaClasses(arguments)
+ val method = obj.getClass.getDeclaredMethod(functionName, argClasses :
_*)
--- End diff --
We should also check if `obj` is `null` too.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]