Skip to content

Commit a032106

Browse files
committed
Properly unset configs.
1 parent 14f2b41 commit a032106

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ class PruneFiltersSuite extends PlanTest {
161161
Inner, Some("tr1.a".attr === "tr2.a".attr)).analyze
162162
comparePlans(optimized, correctAnswer)
163163
} finally {
164-
SQLConf.get.setConf(SQLConf.CONSTRAINT_PROPAGATION_ENABLED, true)
164+
SQLConf.get.unsetConf(SQLConf.CONSTRAINT_PROPAGATION_ENABLED)
165165
}
166166
}
167167
}

sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/plans/ConstraintPropagationSuite.scala

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -400,22 +400,26 @@ class ConstraintPropagationSuite extends SparkFunSuite {
400400
}
401401

402402
test("enable/disable constraint propagation") {
403-
val tr = LocalRelation('a.int, 'b.string, 'c.int)
404-
val filterRelation = tr.where('a.attr > 10)
403+
try {
404+
val tr = LocalRelation('a.int, 'b.string, 'c.int)
405+
val filterRelation = tr.where('a.attr > 10)
405406

406-
SQLConf.get.setConf(SQLConf.CONSTRAINT_PROPAGATION_ENABLED, true)
407-
assert(filterRelation.analyze.constraints.nonEmpty)
407+
SQLConf.get.setConf(SQLConf.CONSTRAINT_PROPAGATION_ENABLED, true)
408+
assert(filterRelation.analyze.constraints.nonEmpty)
408409

409-
SQLConf.get.setConf(SQLConf.CONSTRAINT_PROPAGATION_ENABLED, false)
410-
assert(filterRelation.analyze.constraints.isEmpty)
410+
SQLConf.get.setConf(SQLConf.CONSTRAINT_PROPAGATION_ENABLED, false)
411+
assert(filterRelation.analyze.constraints.isEmpty)
411412

412-
val aliasedRelation = tr.where('c.attr > 10 && 'a.attr < 5)
413-
.groupBy('a, 'c, 'b)('a, 'c.as("c1"), count('a).as("a3")).select('c1, 'a, 'a3)
413+
val aliasedRelation = tr.where('c.attr > 10 && 'a.attr < 5)
414+
.groupBy('a, 'c, 'b)('a, 'c.as("c1"), count('a).as("a3")).select('c1, 'a, 'a3)
414415

415-
SQLConf.get.setConf(SQLConf.CONSTRAINT_PROPAGATION_ENABLED, true)
416-
assert(aliasedRelation.analyze.constraints.nonEmpty)
416+
SQLConf.get.setConf(SQLConf.CONSTRAINT_PROPAGATION_ENABLED, true)
417+
assert(aliasedRelation.analyze.constraints.nonEmpty)
417418

418-
SQLConf.get.setConf(SQLConf.CONSTRAINT_PROPAGATION_ENABLED, false)
419-
assert(aliasedRelation.analyze.constraints.isEmpty)
419+
SQLConf.get.setConf(SQLConf.CONSTRAINT_PROPAGATION_ENABLED, false)
420+
assert(aliasedRelation.analyze.constraints.isEmpty)
421+
} finally {
422+
SQLConf.get.unsetConf(SQLConf.CONSTRAINT_PROPAGATION_ENABLED)
423+
}
420424
}
421425
}

0 commit comments

Comments
 (0)