Skip to content

Commit 5a735af

Browse files
committed
Don't use hardcoded configs.
1 parent 8c56ae4 commit 5a735af

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,14 @@ class CodeGeneratorWithInterpretedFallbackSuite extends SparkFunSuite with PlanT
2828
val input = Seq(LongType, IntegerType)
2929
.zipWithIndex.map(x => BoundReference(x._2, x._1, true))
3030

31-
withSQLConf(SQLConf.CODEGEN_FACTORY_MODE.key -> "CODEGEN_ONLY") {
31+
val codegenOnly = CodegenObjectFactoryMode.CODEGEN_ONLY.toString
32+
withSQLConf(SQLConf.CODEGEN_FACTORY_MODE.key -> codegenOnly) {
3233
val obj = UnsafeProjection.createObject(input)
3334
assert(obj.getClass.getName.contains("GeneratedClass$SpecificUnsafeProjection"))
3435
}
3536

36-
withSQLConf(SQLConf.CODEGEN_FACTORY_MODE.key -> "NO_CODEGEN") {
37+
val noCodegen = CodegenObjectFactoryMode.NO_CODEGEN.toString
38+
withSQLConf(SQLConf.CODEGEN_FACTORY_MODE.key -> noCodegen) {
3739
val obj = UnsafeProjection.createObject(input)
3840
assert(obj.isInstanceOf[InterpretedUnsafeProjection])
3941
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,9 @@ trait ExpressionEvalHelper extends GeneratorDrivenPropertyChecks with PlanTestBa
197197
expression: Expression,
198198
expected: Any,
199199
inputRow: InternalRow = EmptyRow): Unit = {
200-
for (fallbackMode <- Seq("CODEGEN_ONLY", "NO_CODEGEN")) {
201-
withSQLConf(SQLConf.CODEGEN_FACTORY_MODE.key -> fallbackMode) {
200+
val modes = Seq(CodegenObjectFactoryMode.CODEGEN_ONLY, CodegenObjectFactoryMode.NO_CODEGEN)
201+
for (fallbackMode <- modes) {
202+
withSQLConf(SQLConf.CODEGEN_FACTORY_MODE.key -> fallbackMode.toString) {
202203
val unsafeRow = evaluateWithUnsafeProjection(expression, inputRow)
203204
val input = if (inputRow == EmptyRow) "" else s", input: $inputRow"
204205

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,10 @@ class UnsafeRowConverterSuite extends SparkFunSuite with Matchers with PlanTestB
3636
private def roundedSize(size: Int) = ByteArrayMethods.roundNumberOfBytesToNearestWord(size)
3737

3838
private def testBothCodegenAndInterpreted(name: String)(f: => Unit): Unit = {
39-
for (fallbackMode <- Seq("CODEGEN_ONLY", "NO_CODEGEN")) {
39+
val modes = Seq(CodegenObjectFactoryMode.CODEGEN_ONLY, CodegenObjectFactoryMode.NO_CODEGEN)
40+
for (fallbackMode <- modes) {
4041
test(name + " with " + fallbackMode) {
41-
withSQLConf(SQLConf.CODEGEN_FACTORY_MODE.key -> fallbackMode) {
42+
withSQLConf(SQLConf.CODEGEN_FACTORY_MODE.key -> fallbackMode.toString) {
4243
f
4344
}
4445
}

0 commit comments

Comments
 (0)