Github user gatorsmile commented on a diff in the pull request:
https://github.com/apache/spark/pull/15238#discussion_r80787675
--- Diff:
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/SetOperationSuite.scala
---
@@ -76,4 +77,32 @@ class SetOperationSuite extends PlanTest {
testRelation3.select('g) :: Nil).analyze
comparePlans(unionOptimized, unionCorrectAnswer)
}
+
+ test("no more unnecessary distincts in multiple unions") {
+ val query1 = OneRowRelation
+ .select(Literal(1).as('a))
+ val query2 = OneRowRelation
+ .select(Literal(2).as('b))
+ val query3 = OneRowRelation
+ .select(Literal(3).as('c))
+
+ val unionQuery1 = Distinct(Union(Distinct(Union(query1, query2)),
query3)).analyze
+ val optimized1 = Optimize.execute(unionQuery1)
+ val distinctUnionCorrectAnswer1 =
+ Distinct(Union(query1 :: query2 :: query3 :: Nil)).analyze
+ comparePlans(distinctUnionCorrectAnswer1, optimized1)
+
+ val unionQuery2 = Union(Distinct(Union(query1, query2)),
query3).analyze
--- End diff --
```
U - D - U - query1
| |
query3 query2
```
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]