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

    https://github.com/apache/spark/pull/21193#discussion_r186624071
  
    --- 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 --
    
    During changing to `Block` in `Cast`, I do think of this again.
    
    `eval` is the only expression for `Cast`, thus it should be the only 
`ExprValue` input to `Cast`'s code block we need to take care.
    
    Other `ExprValue` like the children of `eval.value` should be taken care in 
the block 
    `eval.code`.



---

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

Reply via email to