Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Move unit test into DataFrameJoinSuite, test LeftSemi too
  • Loading branch information
EnricoMi committed Nov 18, 2022
commit 7333c31aba791c94fd0c169569d17a4f36718a12
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,24 @@ class DataFrameJoinSuite extends QueryTest
}
}

Seq("left_semi", "left_anti").foreach { joinType =>
test(s"SPARK-41162: $joinType self-joined aggregated dataframe") {
// aggregated dataframe
val ids = Seq(1, 2, 3).toDF("id").distinct()

// self-joined via joinType
val result = ids.withColumn("id", $"id" + 1)
.join(ids, "id", joinType).collect()

val expected = joinType match {
case "left_semi" => 2
case "left_anti" => 1
case _ => -1 // unsupported test type, test will always fail
}
assert(result.length == expected)
}
}

def extractLeftDeepInnerJoins(plan: LogicalPlan): Seq[LogicalPlan] = plan match {
case j @ Join(left, right, _: InnerLike, _, _) => right +: extractLeftDeepInnerJoins(left)
case Filter(_, child) => extractLeftDeepInnerJoins(child)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,6 @@ class DataFrameSuite extends QueryTest
with AdaptiveSparkPlanHelper {
import testImplicits._

test("aggr antijoin") {
val ids = Seq(1, 2, 3).toDF("id").distinct()
val result = ids.withColumn("id", $"id" + 1)
.join(ids, "id", "left_anti").collect()
assert(result.length == 1)
}

test("analysis error should be eagerly reported") {
intercept[Exception] { testData.select("nonExistentName") }
intercept[Exception] {
Expand Down