You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by hvanhovell <gi...@git.apache.org> on 2018/04/02 22:40:38 UTC

[GitHub] spark pull request #20797: [SPARK-23583][SQL] Invoke should support interpre...

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

    https://github.com/apache/spark/pull/20797#discussion_r178670249
  
    --- 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 --
    
    Why are we resolving during evaluation time? This seems to be expensive?


---

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