jchen5 commented on code in PR #39759:
URL: https://github.com/apache/spark/pull/39759#discussion_r1093439068


##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/DecorrelateInnerQuerySuite.scala:
##########
@@ -333,6 +334,114 @@ class DecorrelateInnerQuerySuite extends PlanTest {
     check(innerPlan, outerPlan, correctAnswer, Seq(x <=> x, y <=> y, z <=> z))
   }
 
+  test("INTERSECT ALL in correlation path") {
+    val outerPlan = testRelation2
+    val innerPlan =
+      Intersect(
+        Filter(And(OuterReference(x) === a, c === 3),
+          testRelation),
+        Filter(And(OuterReference(y) === b, c === 6),
+          testRelation),
+        isAll = true)
+    val correctAnswer =
+      Intersect(
+        Project(Seq(a, b, c, x, y),
+          Filter(And(x === a, c === 3),
+            DomainJoin(Seq(x, y),
+              testRelation))),
+        Project(Seq(a, b, c, x, y),
+          Filter(And(y === b, c === 6),
+            DomainJoin(Seq(x.newInstance(), y.newInstance()),
+              testRelation))),
+        isAll = true
+      )
+    // Disable checkAnalysis because otherwise duplicate attributes hit

Review Comment:
   It's a specific analysis check for the two sides of intersect/except having 
disjoin attributes:
   ```
   case i: Intersect if !i.duplicateResolved =>
               val conflictingAttributes = 
i.left.outputSet.intersect(i.right.outputSet)
               i.failAnalysis(
   ```
   I was able to modify the test to bypass it - previously I tried but got an 
issue with missing attributes, this time I was able to modify the test to get 
around that too.



##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/DecorrelateInnerQuerySuite.scala:
##########
@@ -333,6 +334,114 @@ class DecorrelateInnerQuerySuite extends PlanTest {
     check(innerPlan, outerPlan, correctAnswer, Seq(x <=> x, y <=> y, z <=> z))
   }
 
+  test("INTERSECT ALL in correlation path") {
+    val outerPlan = testRelation2
+    val innerPlan =
+      Intersect(
+        Filter(And(OuterReference(x) === a, c === 3),
+          testRelation),
+        Filter(And(OuterReference(y) === b, c === 6),
+          testRelation),
+        isAll = true)
+    val correctAnswer =
+      Intersect(
+        Project(Seq(a, b, c, x, y),
+          Filter(And(x === a, c === 3),
+            DomainJoin(Seq(x, y),
+              testRelation))),
+        Project(Seq(a, b, c, x, y),
+          Filter(And(y === b, c === 6),
+            DomainJoin(Seq(x.newInstance(), y.newInstance()),
+              testRelation))),
+        isAll = true
+      )
+    // Disable checkAnalysis because otherwise duplicate attributes hit

Review Comment:
   It's a specific analysis check for the two sides of intersect/except having 
disjoint attributes:
   ```
   case i: Intersect if !i.duplicateResolved =>
               val conflictingAttributes = 
i.left.outputSet.intersect(i.right.outputSet)
               i.failAnalysis(
   ```
   I was able to modify the test to bypass it - previously I tried but got an 
issue with missing attributes, this time I was able to modify the test to get 
around that too.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to