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

    https://github.com/apache/spark/pull/15901#discussion_r88413619
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/objects/objects.scala
 ---
    @@ -33,6 +33,85 @@ import 
org.apache.spark.sql.catalyst.util.{ArrayBasedMapData, GenericArrayData}
     import org.apache.spark.sql.types._
     
     /**
    + * Common base class for [[StaticInvoke]], [[Invoke]], and [[NewInstance]].
    + */
    +trait InvokeLike extends Expression with NonSQLExpression {
    +
    +  def arguments: Seq[Expression]
    +
    +  def propagateNull: Boolean
    +
    +  protected lazy val needNullCheck: Boolean = propagateNull && 
arguments.exists(_.nullable)
    +
    +  /**
    +   * Prepares codes for arguments.
    +   *
    +   * - generate codes for argument.
    +   * - use ctx.splitExpressions() to not exceed 64kb JVM limit while 
preparing arguments.
    +   * - avoid some of nullabilty checking which are not needed because the 
expression is not
    +   *   nullable.
    +   * - when needNullCheck == true, short circuit if we found one of 
arguments is null because
    +   *   preparing rest of arguments can be skipped in the case.
    +   *
    +   * @param ctx a [[CodegenContext]]
    +   * @param ev an [[ExprCode]] with unique terms.
    +   * @return (code to prepare arguments, argument string, code to set 
isNull)
    +   */
    +  def prepareArguments(ctx: CodegenContext, ev: ExprCode): (String, 
String, String) = {
    +
    +    val containsNullInArguments = if (needNullCheck) {
    +      val containsNullInArguments = 
ctx.freshName("containsNullInArguments")
    +      ctx.addMutableState("boolean", containsNullInArguments, "")
    +      containsNullInArguments
    +    } else {
    +      ""
    +    }
    +    val argValues = arguments.zipWithIndex.map { case (e, i) =>
    +      val argValue = ctx.freshName("argValue")
    +      ctx.addMutableState(ctx.javaType(e.dataType), argValue, "")
    +      argValue
    +    }
    +
    +    val argCodes = if (needNullCheck) {
    +      val reset = s"$containsNullInArguments = false;"
    +      val argCodes = arguments.zipWithIndex.map { case (e, i) =>
    +        val expr = e.genCode(ctx)
    +        val updateContainsNull = if (e.nullable) {
    +          s"$containsNullInArguments = ${expr.isNull};"
    +        } else {
    +          ""
    +        }
    +        s"""
    +          if (!$containsNullInArguments) {
    --- End diff --
    
    @kiszk I'm sorry but I didn't understand what you mean.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to