Github user kiszk commented on a diff in the pull request:
https://github.com/apache/spark/pull/20797#discussion_r178753061
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/objects/objects.scala
---
@@ -263,11 +295,21 @@ case class Invoke(
propagateNull: Boolean = true,
returnNullable : Boolean = true) extends InvokeLike {
+ lazy val argClasses = ScalaReflection.expressionJavaClasses(arguments)
+
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)
+ if (obj == null) {
+ // return null if obj is null
+ null
+ } else {
+ val method = obj.getClass.getDeclaredMethod(functionName, argClasses
: _*)
--- End diff --
Unlike `StaticInvoke`, this is because `obj` is dynamically evaluated with
a value in `InternalRow`. We cannot resolve beforehand when the case class is
created.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]