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 #21193: [SPARK-24121][SQL] Add API for handling expressio...
Date Tue, 08 May 2018 06:24:30 GMT
Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21193#discussion_r186627099
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala
---
    @@ -623,8 +624,14 @@ case class Cast(child: Expression, dataType: DataType, timeZoneId:
Option[String
       override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = {
         val eval = child.genCode(ctx)
         val nullSafeCast = nullSafeCastFunction(child.dataType, dataType, ctx)
    +
    +    // Below the code comment including `eval.value` and `eval.isNull` is a trick. It
makes the two
    +    // expr values are referred by this code block.
         ev.copy(code = eval.code +
    -      castCode(ctx, eval.value, eval.isNull, ev.value, ev.isNull, dataType, nullSafeCast))
    +      code"""
    +        // Cast from ${eval.value}, ${eval.isNull}
    --- End diff --
    
    I feel it's a little fragile to depend on the `StringContext` to collect references. 2
proposal:
    1. ask the code builder to explicitly specify the references, like `JavaCode.block(code
= xxx, ref1, ref2, ...)`
    2. ban `String` in the code block string context, and create a special class to insert
`String` literal to code block, so that we won't mistakently pass code as string and lose
references.


---

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


Mime
View raw message