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: [SPARK-8590][SQL] add code gen for ExtractValu...
Date Mon, 29 Jun 2015 13:13:49 GMT
Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/6982#discussion_r33461668
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Expression.scala
---
    @@ -245,13 +254,26 @@ abstract class UnaryExpression extends Expression with trees.UnaryNode[Expressio
           ctx: CodeGenContext,
           ev: GeneratedExpressionCode,
           f: String => String): String = {
    +    nullSafeCodeGen(ctx, ev, (result, eval) => {
    +      s"$result = ${f(eval)};"
    +    })
    +  }
    +
    +  /**
    +   * Called by unary expressions to generate a code block that returns null if its parent
returns
    +   * null, and if not not null, use `f` to generate the expression.
    +   */
    +  protected def nullSafeCodeGen(
    +      ctx: CodeGenContext,
    +      ev: GeneratedExpressionCode,
    +      f: (String, String) => String): String = {
         val eval = child.gen(ctx)
    -    // reuse the previous isNull
    -    ev.isNull = eval.isNull
    --- End diff --
    
    I removed this because if `child` is `Literal`, then `eval.isNull` is literal boolean,
and we can't change `ev.isNull` afterwards. It's not a problem before as we won't change `ev.isNull`
in `defineCodeGen`, but now we will and need to do it in `nullSafeCodeGen`.


---
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