Github user viirya commented on a diff in the pull request:

    https://github.com/apache/spark/pull/20753#discussion_r172717961
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/objects/objects.scala
 ---
    @@ -133,8 +134,21 @@ case class StaticInvoke(
       override def nullable: Boolean = needNullCheck || returnNullable
       override def children: Seq[Expression] = arguments
     
    -  override def eval(input: InternalRow): Any =
    -    throw new UnsupportedOperationException("Only code-generated 
evaluation is supported.")
    +  override def eval(input: InternalRow): Any = {
    +    if (staticObject == null) {
    +      throw new RuntimeException("The static class cannot be null.")
    +    }
    +
    +    val parmTypes = arguments.map(e =>
    +      CallMethodViaReflection.typeMapping.getOrElse(e.dataType,
    +        Seq(e.dataType.asInstanceOf[ObjectType].cls))(0))
    +    val parms = arguments.map(e => e.eval(input).asInstanceOf[Object])
    +    val method = staticObject.getDeclaredMethod(functionName, parmTypes : 
_*)
    +    val ret = method.invoke(null, parms : _*)
    +    val retClass = CallMethodViaReflection.typeMapping.getOrElse(dataType,
    +      Seq(dataType.asInstanceOf[ObjectType].cls))(0)
    --- End diff --
    
    Will `dataType` always be an `ObjectType` here?


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to