Skip to content

Commit 9ad4a6e

Browse files
Surbhi-Vijayviirya
authored andcommitted
[MINOR][SQL][TESTS] Remove duplicated plan node check in DataFrameSetOperationsSuite
### What changes were proposed in this pull request? Remove duplicated plan node check in DataFrameSetOperationsSuite ### Why are the changes needed? Code is unnecessarily checking for `InMemoryTableScanExec` in executed plan twice. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? UT ### Was this patch authored or co-authored using generative AI tooling? No Closes #50227 from Surbhi-Vijay/RefactorDataframeTest. Authored-by: Surbhi Vijayvargeeya <surbhivijayvargeeya@gmail.com> Signed-off-by: Liang-Chi Hsieh <viirya@gmail.com>
1 parent 0094f44 commit 9ad4a6e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

sql/core/src/test/scala/org/apache/spark/sql/DataFrameSetOperationsSuite.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1478,11 +1478,13 @@ class DataFrameSetOperationsSuite extends QueryTest
14781478
def checkIfColumnar(
14791479
plan: SparkPlan,
14801480
targetPlan: (SparkPlan) => Boolean,
1481-
isColumnar: Boolean): Unit = {
1481+
isColumnar: Boolean,
1482+
targetPlanNum: Int): Unit = {
14821483
val target = collect(plan) {
14831484
case p if targetPlan(p) => p
14841485
}
14851486
assert(target.nonEmpty)
1487+
assert(target.size == targetPlanNum)
14861488
assert(target.forall(_.supportsColumnar == isColumnar))
14871489
}
14881490

@@ -1494,15 +1496,13 @@ class DataFrameSetOperationsSuite extends QueryTest
14941496
val union = df1.union(df2)
14951497
union.collect()
14961498
checkIfColumnar(union.queryExecution.executedPlan,
1497-
_.isInstanceOf[InMemoryTableScanExec], supported)
1498-
checkIfColumnar(union.queryExecution.executedPlan,
1499-
_.isInstanceOf[InMemoryTableScanExec], supported)
1500-
checkIfColumnar(union.queryExecution.executedPlan, _.isInstanceOf[UnionExec], supported)
1499+
_.isInstanceOf[InMemoryTableScanExec], supported, 2)
1500+
checkIfColumnar(union.queryExecution.executedPlan, _.isInstanceOf[UnionExec], supported, 1)
15011501
checkAnswer(union, Row(1) :: Row(2) :: Row(3) :: Row(4) :: Row(5) :: Row(6) :: Nil)
15021502

15031503
val nonColumnarUnion = df1.union(Seq(7, 8, 9).toDF("k"))
15041504
checkIfColumnar(nonColumnarUnion.queryExecution.executedPlan,
1505-
_.isInstanceOf[UnionExec], false)
1505+
_.isInstanceOf[UnionExec], false, 1)
15061506
checkAnswer(nonColumnarUnion,
15071507
Row(1) :: Row(2) :: Row(3) :: Row(7) :: Row(8) :: Row(9) :: Nil)
15081508
}

0 commit comments

Comments
 (0)