Skip to content

Commit 8225e94

Browse files
committed
test
1 parent d083773 commit 8225e94

File tree

1 file changed

+5
-87
lines changed

1 file changed

+5
-87
lines changed

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

Lines changed: 5 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -809,92 +809,7 @@ class JoinSuite extends QueryTest with SharedSparkSession with AdaptiveSparkPlan
809809
withSQLConf(SQLConf.AUTO_BROADCASTJOIN_THRESHOLD.key -> "1",
810810
SQLConf.SORT_MERGE_JOIN_EXEC_BUFFER_IN_MEMORY_THRESHOLD.key -> "0",
811811
SQLConf.SORT_MERGE_JOIN_EXEC_BUFFER_SPILL_THRESHOLD.key -> "1") {
812-
813-
assertSpilled(sparkContext, "inner join") {
814-
checkAnswer(
815-
sql("SELECT * FROM testData JOIN testData2 ON key = a where key = 2"),
816-
Row(2, "2", 2, 1) :: Row(2, "2", 2, 2) :: Nil
817-
)
818-
}
819-
820-
// LEFT SEMI JOIN without bound condition does not spill
821-
assertNotSpilled(sparkContext, "left semi join") {
822-
checkAnswer(
823-
sql("SELECT * FROM testData LEFT SEMI JOIN testData2 ON key = a WHERE key = 2"),
824-
Row(2, "2") :: Nil
825-
)
826-
}
827-
828-
// LEFT ANTI JOIN without bound condition does not spill
829-
assertNotSpilled(sparkContext, "left anti join") {
830-
checkAnswer(
831-
sql("SELECT * FROM testData LEFT ANTI JOIN testData2 ON key = a WHERE key = 2"),
832-
Nil
833-
)
834-
}
835-
836-
val expected = new ListBuffer[Row]()
837-
expected.appendAll(Seq(
838-
Row(1, "1", 1, 1), Row(1, "1", 1, 2),
839-
Row(2, "2", 2, 1), Row(2, "2", 2, 2),
840-
Row(3, "3", 3, 1), Row(3, "3", 3, 2))
841-
)
842-
for (i <- 4 to 100) {
843-
expected.append(Row(i, i.toString, null, null))
844-
}
845-
846-
assertSpilled(sparkContext, "left outer join") {
847-
checkAnswer(
848-
sql(
849-
"""
850-
|SELECT
851-
| big.key, big.value, small.a, small.b
852-
|FROM
853-
| testData big
854-
|LEFT OUTER JOIN
855-
| testData2 small
856-
|ON
857-
| big.key = small.a
858-
""".stripMargin),
859-
expected.toSeq
860-
)
861-
}
862-
863-
assertSpilled(sparkContext, "right outer join") {
864-
checkAnswer(
865-
sql(
866-
"""
867-
|SELECT
868-
| big.key, big.value, small.a, small.b
869-
|FROM
870-
| testData2 small
871-
|RIGHT OUTER JOIN
872-
| testData big
873-
|ON
874-
| big.key = small.a
875-
""".stripMargin),
876-
expected.toSeq
877-
)
878-
}
879-
880-
// FULL OUTER JOIN still does not use [[ExternalAppendOnlyUnsafeRowArray]]
881-
// so should not cause any spill
882-
assertNotSpilled(sparkContext, "full outer join") {
883-
checkAnswer(
884-
sql(
885-
"""
886-
|SELECT
887-
| big.key, big.value, small.a, small.b
888-
|FROM
889-
| testData2 small
890-
|FULL OUTER JOIN
891-
| testData big
892-
|ON
893-
| big.key = small.a
894-
""".stripMargin),
895-
expected.toSeq
896-
)
897-
}
812+
testSpill()
898813
}
899814
}
900815

@@ -903,7 +818,11 @@ class JoinSuite extends QueryTest with SharedSparkSession with AdaptiveSparkPlan
903818
SQLConf.SORT_MERGE_JOIN_EXEC_BUFFER_IN_MEMORY_THRESHOLD.key -> "0",
904819
SQLConf.SORT_MERGE_JOIN_EXEC_BUFFER_SPILL_THRESHOLD.key -> Int.MaxValue.toString,
905820
SQLConf.SORT_MERGE_JOIN_EXEC_BUFFER_SIZE_SPILL_THRESHOLD.key -> "1") {
821+
testSpill()
822+
}
823+
}
906824

825+
private def testSpill(): Unit = {
907826
assertSpilled(sparkContext, "inner join") {
908827
checkAnswer(
909828
sql("SELECT * FROM testData JOIN testData2 ON key = a where key = 2"),
@@ -990,7 +909,6 @@ class JoinSuite extends QueryTest with SharedSparkSession with AdaptiveSparkPlan
990909
)
991910
}
992911
}
993-
}
994912

995913
test("outer broadcast hash join should not throw NPE") {
996914
withTempView("v1", "v2") {

0 commit comments

Comments
 (0)