Skip to content

Commit a455ac3

Browse files
committed
address review comments
1 parent cd4c696 commit a455ac3

File tree

3 files changed

+11
-25
lines changed

3 files changed

+11
-25
lines changed

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

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import java.util.{Calendar, Locale, TimeZone}
2323
import org.apache.spark.SparkFunSuite
2424
import org.apache.spark.sql.Row
2525
import org.apache.spark.sql.catalyst.InternalRow
26+
import org.apache.spark.sql.catalyst.expressions.codegen.CodegenContext
2627
import org.apache.spark.sql.catalyst.util.DateTimeTestUtils._
2728
import org.apache.spark.sql.catalyst.util.DateTimeUtils
2829
import org.apache.spark.sql.catalyst.util.DateTimeUtils.TimeZoneGMT
@@ -846,23 +847,10 @@ class CastSuite extends SparkFunSuite with ExpressionEvalHelper {
846847
checkEvaluation(cast(Literal.create(inputOuter, fromOuter), toOuter), outputOuter)
847848
}
848849

849-
test("SPARK-22570: should not create a lot of instance variables") {
850-
val N = 30000
851-
852-
val from1 = new StructType(
853-
(1 to N).map(i => StructField(s"s$i", StringType)).toArray)
854-
val to1 = new StructType(
855-
(1 to N).map(i => StructField(s"i$i", IntegerType)).toArray)
856-
val input1 = Row.fromSeq((1 to N).map(i => i.toString))
857-
val output1 = Row.fromSeq((1 to N))
858-
checkEvaluation(cast(Literal.create(input1, from1), to1), output1)
859-
860-
val from2 = new StructType(
861-
(1 to N).map(i => StructField(s"s$i", StringType)).toArray)
862-
val to2 = new StructType(
863-
(1 to N).map(i => StructField(s"i$i", LongType)).toArray)
864-
val input2 = Row.fromSeq((1 to N).map(i => i.toString))
865-
val output2 = Row.fromSeq((1 to N).map(i => i.toLong))
866-
checkEvaluation(cast(Literal.create(input2, from2), to2), output2)
850+
test("SPARK-22570: Cast should not create a lot of instance variables") {
851+
val ctx = new CodegenContext
852+
cast("1", IntegerType).genCode(ctx).code
853+
cast("2", LongType).genCode(ctx).code
854+
assert(ctx.mutableStates.length == 0)
867855
}
868856
}

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,14 +179,12 @@ class RegexpExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper {
179179
checkEvaluation(nonNullExpr, "num-num", row1)
180180
}
181181

182-
test("SPARK-22570: should not create a lot of instance variables") {
183-
val N = 16000
184-
val expr = RegExpReplace(Literal("100"), Literal("(\\d+)"), Literal("num"))
182+
test("SPARK-22570: RegExpReplace should not create a lot of global variables") {
185183
val ctx = new CodegenContext
186-
(1 to N).map(_ => expr.genCode(ctx).code)
184+
RegExpReplace(Literal("100"), Literal("(\\d+)"), Literal("num")).genCode(ctx)
187185
// four global variables (lastRegex, pattern, lastReplacement, and lastReplacementInUTF8)
188186
// are always required
189-
assert(ctx.mutableStates.length == 4 * N)
187+
assert(ctx.mutableStates.length == 4)
190188
}
191189

192190
test("RegexExtract") {

sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/complexTypesSuite.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,9 @@ class ComplexTypesSuite extends PlanTest{
165165
comparePlans(Optimizer execute query, expected)
166166
}
167167

168-
test("SPARK-22570: should not create a lot of instance variables") {
168+
test("SPARK-22570: CreateArray should not create a lot of global variables") {
169169
val ctx = new CodegenContext
170-
(1 to 60000).map(i => CreateArray(Seq(Literal(s"$i"))).genCode(ctx).code)
170+
CreateArray(Seq(Literal(1))).genCode(ctx).code
171171
assert(ctx.mutableStates.length == 0)
172172
}
173173

0 commit comments

Comments
 (0)