Github user wzhfy commented on a diff in the pull request:
https://github.com/apache/spark/pull/20345#discussion_r180328615
--- Diff:
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/JoinOptimizationSuite.scala
---
@@ -145,4 +161,55 @@ class JoinOptimizationSuite extends PlanTest {
}
assert(broadcastChildren.size == 1)
}
+
+ test("SPARK-23172 skip projections when flattening joins") {
+ val x = testRelation.subquery('x)
+ val y = testRelation1.subquery('y)
+ val z = testRelation.subquery('z)
+ val joined = x.join(z, Inner, Some($"x.b" === $"z.b")).select($"x.a",
$"z.a", $"z.c")
+ .join(y, Inner, Some($"y.d" === $"z.a")).analyze
+ val expectedTables = joined.collectLeaves().map { case p => (p, Inner)
}
+ val expectedConditions = joined.collect { case Join(_, _, _,
Some(conditions)) => conditions }
+ testExtractInnerJoins(joined, Some((expectedTables,
expectedConditions)))
+ }
+
+ test("SPARK-23172 reorder joins with projections") {
--- End diff --
The case can also happen without star schema enabled, right? Is it possible
to use a simpler case like the one in pr description?
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]