spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cloud-fan <...@git.apache.org>
Subject [GitHub] spark pull request #15901: [SPARK-18467][SQL] Extracts method for preparing ...
Date Fri, 18 Nov 2016 03:00:36 GMT
Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15901#discussion_r88592721
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/objects/objects.scala
---
    @@ -164,23 +233,20 @@ case class Invoke(
           """
         }
     
    -    val setIsNull = if (propagateNull && arguments.nonEmpty) {
    -      s"boolean ${ev.isNull} = ${obj.isNull} || ${argGen.map(_.isNull).mkString(" ||
")};"
    -    } else {
    -      s"boolean ${ev.isNull} = ${obj.isNull};"
    -    }
    -
         // If the function can return null, we do an extra check to make sure our null bit
is still set
         // correctly.
         val postNullCheck = if (ctx.defaultValue(dataType) == "null") {
           s"${ev.isNull} = ${ev.value} == null;"
         } else {
           ""
         }
    +
         val code = s"""
           ${obj.code}
    -      ${argGen.map(_.code).mkString("\n")}
    -      $setIsNull
    +      if (!${obj.isNull}) {
    +        $argCode
    +      }
    +      boolean ${ev.isNull} = ${obj.isNull} || $resultIsNull;
    --- End diff --
    
    this assumes `resultIsNull` is a member variable not local variable, can we avoid doing
this? We can make the code clearer and more robust like:
    ```
    javaType ${ev.value} = defaultValue;
    boolean ${ev.isNull} = true;
    if (!${obj.isNull}) {
      $argCode
      ${ev.isNull} = $resultIsNull
      ...
      $postNullCheck
    }
    
    ```


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


Mime
View raw message