Skip to content

Commit cb9fc8d

Browse files
kiszkcloud-fan
authored andcommitted
[SPARK-22848][SQL] Eliminate mutable state from Stack
## What changes were proposed in this pull request? This PR eliminates mutable states from the generated code for `Stack`. ## How was this patch tested? Existing test suites Author: Kazuaki Ishizaki <[email protected]> Closes #20035 from kiszk/SPARK-22848.
1 parent d3ae3e1 commit cb9fc8d

File tree

1 file changed

+5
-5
lines changed
  • sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions

1 file changed

+5
-5
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/generators.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,11 @@ case class Stack(children: Seq[Expression]) extends Generator {
214214

215215
// Create the collection.
216216
val wrapperClass = classOf[mutable.WrappedArray[_]].getName
217-
ctx.addMutableState(
218-
s"$wrapperClass<InternalRow>",
219-
ev.value,
220-
v => s"$v = $wrapperClass$$.MODULE$$.make($rowData);", useFreshName = false)
221-
ev.copy(code = code, isNull = "false")
217+
ev.copy(code =
218+
s"""
219+
|$code
220+
|$wrapperClass<InternalRow> ${ev.value} = $wrapperClass$$.MODULE$$.make($rowData);
221+
""".stripMargin, isNull = "false")
222222
}
223223
}
224224

0 commit comments

Comments
 (0)