Skip to content

Commit d126977

Browse files
committed
address comment
1 parent e63bb6e commit d126977

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

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

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -118,26 +118,21 @@ abstract class Expression extends TreeNode[Expression] {
118118
""
119119
}
120120

121-
val setValue = {
122-
val globalValue = ctx.freshName("globalValue")
123-
ctx.addMutableState(
124-
ctx.javaType(dataType), globalValue, s"$globalValue = ${ctx.defaultValue(dataType)};")
125-
val localValue = ve.value
126-
ve.value = globalValue
127-
s"$globalValue = $localValue;"
128-
}
121+
val javaType = ctx.javaType(dataType)
122+
val newValue = ctx.freshName("value")
129123

130124
val funcName = ctx.freshName(nodeName)
131125
val funcFullName = ctx.addNewFunction(funcName,
132126
s"""
133-
|private void $funcName(InternalRow ${ctx.INPUT_ROW}) {
127+
|private $javaType $funcName(InternalRow ${ctx.INPUT_ROW}) {
134128
| ${ve.code.trim}
135-
| $setValue
136129
| $setIsNull
130+
| return ${ve.value};
137131
|}
138132
""".stripMargin)
139133

140-
ve.code = s"$funcFullName(${ctx.INPUT_ROW});"
134+
ve.value = newValue
135+
ve.code = s"$javaType $newValue = $funcFullName(${ctx.INPUT_ROW});"
141136
}
142137

143138
if (ve.code.nonEmpty) {

sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/CodeGenerationSuite.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class CodeGenerationSuite extends SparkFunSuite with ExpressionEvalHelper {
9797
assert(actual(0) == cases)
9898
}
9999

100-
test("SPARK-18091: split large if expressions into blocks due to JVM code size limit") {
100+
test("SPARK-22543: split large if expressions into blocks due to JVM code size limit") {
101101
var strExpr: Expression = Literal("abc")
102102
for (_ <- 1 to 150) {
103103
strExpr = Decode(Encode(strExpr, "utf-8"), "utf-8")
@@ -342,7 +342,7 @@ class CodeGenerationSuite extends SparkFunSuite with ExpressionEvalHelper {
342342
projection(row)
343343
}
344344

345-
test("SPARK-21720: split large predications into blocks due to JVM code size limit") {
345+
test("SPARK-22543: split large predicates into blocks due to JVM code size limit") {
346346
val length = 600
347347

348348
val input = new GenericInternalRow(length)

0 commit comments

Comments
 (0)