Github user cloud-fan commented on a diff in the pull request:
https://github.com/apache/spark/pull/19797#discussion_r152664308
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Cast.scala
---
@@ -851,9 +855,11 @@ case class Cast(child: Expression, dataType: DataType,
timeZoneId: Option[String
private[this] def castToIntCode(from: DataType, ctx: CodegenContext):
CastFunction = from match {
case StringType =>
- val wrapper = ctx.freshName("wrapper")
- ctx.addMutableState("UTF8String.IntWrapper", wrapper,
- s"$wrapper = new UTF8String.IntWrapper();")
+ val wrapper = "intWrapper"
+ if (!ctx.mutableStates.exists(s => s._1 == wrapper)) {
+ ctx.addMutableState("UTF8String.IntWrapper", wrapper,
+ s"$wrapper = new UTF8String.IntWrapper();")
+ }
(c, evPrim, evNull) =>
s"""
if ($c.toInt($wrapper)) {
--- End diff --
what if we create a new wrapper every time?
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]