Github user ueshin commented on a diff in the pull request: https://github.com/apache/spark/pull/21193#discussion_r186681857 --- 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} + ${castCode(ctx, eval.value, eval.isNull, ev.value, ev.isNull, dataType, nullSafeCast)} --- End diff -- I might miss something, but don't we need to pass `ExprValue` or `Block` and return `Block` from `castCode()` to keep track of code snippets and inputs? We can say the same thing anywhere we create a smaller code snippet using `s` interpolation.
--- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org