maropu commented on a change in pull request #26441: [SPARK-29682][SQL] Resolve 
conflicting references in aggregate expressions 
URL: https://github.com/apache/spark/pull/26441#discussion_r344414748
 
 

 ##########
 File path: sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala
 ##########
 @@ -3304,6 +3304,26 @@ class SQLQuerySuite extends QueryTest with 
SharedSparkSession {
         """.stripMargin).collect()
     }
   }
+
+  test("SPARK-29682: Aggregation conflicts are resolved") {
+    val numsDF = Seq(1, 2, 3).toDF("nums")
+    val cubeDF = numsDF
+      .cube("nums")
+      .agg(max(lit(0)).as("agcol"), grouping_id().as("gid"))
+
+    checkAnswer(
+      cubeDF.select("nums").join(cubeDF, "nums"),
+      Row(1, 0, 0) :: Row(2, 0, 0) :: Row(3, 0, 0) :: Nil)
+
+    val group0 = cubeDF.filter(col("gid") <=> lit(0))
+    val group1 = cubeDF.filter(col("gid") <=> lit(1))
+
+    checkAnswer(
+      cubeDF.select("nums").distinct
+        .join(group0, Seq("nums"), "inner")
+        .join(group1, Seq("nums"), "inner"),
+      Seq.empty)
 
 Review comment:
   Why is this test query different from one in the PR description? I think the 
simpler query in the description is better.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

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

Reply via email to