Skip to content

Commit 8c56ae4

Browse files
committed
Simplify test suite.
1 parent 716d88f commit 8c56ae4

File tree

1 file changed

+7
-23
lines changed

1 file changed

+7
-23
lines changed

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

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -24,34 +24,18 @@ import org.apache.spark.sql.types.{IntegerType, LongType}
2424

2525
class CodeGeneratorWithInterpretedFallbackSuite extends SparkFunSuite with PlanTestBase {
2626

27-
// Given a factory object and corresponding input, checking if `SQLConf.CODEGEN_FACTORY_MODE`
28-
// can switch between codegen/interpreted implementation.
29-
private def testCodegenFactory[IN, OUT](factory: CodeGeneratorWithInterpretedFallback[IN, OUT],
30-
input: IN, checkerForCodegen: OUT => Unit, checkerForInterpreted: OUT => Unit) = {
31-
32-
val modes = Seq("CODEGEN_ONLY", "NO_CODEGEN")
33-
.zip(Seq(checkerForCodegen, checkerForInterpreted))
34-
35-
for ((fallbackMode, checker) <- modes) {
36-
withSQLConf(SQLConf.CODEGEN_FACTORY_MODE.key -> fallbackMode) {
37-
val obj = factory.createObject(input)
38-
checker(obj)
39-
}
40-
}
41-
}
42-
43-
test("test UnsafeProjection factory") {
27+
test("UnsafeProjection with codegen factory mode") {
4428
val input = Seq(LongType, IntegerType)
4529
.zipWithIndex.map(x => BoundReference(x._2, x._1, true))
4630

47-
def checkerForCodegen(projection: UnsafeProjection): Unit = {
48-
assert(projection.getClass.getName.contains("GeneratedClass$SpecificUnsafeProjection"))
31+
withSQLConf(SQLConf.CODEGEN_FACTORY_MODE.key -> "CODEGEN_ONLY") {
32+
val obj = UnsafeProjection.createObject(input)
33+
assert(obj.getClass.getName.contains("GeneratedClass$SpecificUnsafeProjection"))
4934
}
5035

51-
def checkerForInterpreted(projection: UnsafeProjection): Unit = {
52-
assert(projection.isInstanceOf[InterpretedUnsafeProjection])
36+
withSQLConf(SQLConf.CODEGEN_FACTORY_MODE.key -> "NO_CODEGEN") {
37+
val obj = UnsafeProjection.createObject(input)
38+
assert(obj.isInstanceOf[InterpretedUnsafeProjection])
5339
}
54-
55-
testCodegenFactory(UnsafeProjection, input, checkerForCodegen, checkerForInterpreted)
5640
}
5741
}

0 commit comments

Comments
 (0)