Github user cloud-fan commented on a diff in the pull request:
https://github.com/apache/spark/pull/19891#discussion_r154965918
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala
---
@@ -584,15 +584,15 @@ case class Cast(child: Expression, dataType:
DataType, timeZoneId: Option[String
throw new SparkException(s"Cannot cast $from to $to.")
}
- // Since we need to cast child expressions recursively inside
ComplexTypes, such as Map's
+ // Since we need to cast input expressions recursively inside
ComplexTypes, such as Map's
// Key and Value, Struct's field, we need to name out all the variable
names involved in a cast.
- private[this] def castCode(ctx: CodegenContext, childPrim: String,
childNull: String,
- resultPrim: String, resultNull: String, resultType: DataType, cast:
CastFunction): String = {
+ private[this] def castCode(ctx: CodegenContext, input: String,
inputIsNull: String,
+ result: String, resultIsNull: String, resultType: DataType, cast:
CastFunction): String = {
s"""
- boolean $resultNull = $childNull;
- ${ctx.javaType(resultType)} $resultPrim =
${ctx.defaultValue(resultType)};
- if (!$childNull) {
- ${cast(childPrim, resultPrim, resultNull)}
+ boolean $resultIsNull = $inputIsNull;
+ ${ctx.javaType(resultType)} $result =
${ctx.defaultValue(resultType)};
+ if (!$inputIsNull) {
+ ${cast(input, result, resultIsNull)}
--- End diff --
some renaming to make it more readable.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]