godfreyhe commented on a change in pull request #10760: 
[FLINK-15466][table-planner] Fix bug of `FlinkAggregateExpandDistinct…
URL: https://github.com/apache/flink/pull/10760#discussion_r363181207
 
 

 ##########
 File path: 
flink-table/flink-table-planner-blink/src/test/scala/org/apache/flink/table/planner/plan/batch/sql/agg/DistinctAggregateTest.scala
 ##########
 @@ -82,4 +83,39 @@ class DistinctAggregateTest extends TableTestBase {
     util.verifyPlan(sqlQuery)
   }
 
+  @Test
+  def testSingleDistinctWithFilter(): Unit = {
+    val sqlQuery = "SELECT d, COUNT(DISTINCT c) FILTER (WHERE a > 0) FROM 
MyTable2 GROUP BY d"
+    util.verifyPlan(sqlQuery)
+  }
+
+  @Test
+  def testMultiDistinctOnSameColumnWithFilter(): Unit = {
+    val sqlQuery = "SELECT d, COUNT(DISTINCT c), COUNT(DISTINCT c) FILTER 
(WHERE a > 10),\n" +
+      "COUNT(DISTINCT c) FILTER (WHERE a < 10) FROM MyTable2 GROUP BY d"
+    util.verifyPlan(sqlQuery)
+  }
+
+  @Test
+  def TestMultiDistinctOnDifferentColumnWithFilter(): Unit = {
+    val sqlQuery = "SELECT d, COUNT(DISTINCT c), COUNT(DISTINCT c) FILTER 
(WHERE a > 0),\n" +
+      "COUNT(DISTINCT b) FILTER (WHERE b > 1) FROM MyTable2 GROUP BY d"
+    util.verifyPlan(sqlQuery)
+  }
+
+  @Test
+  def TestMultiDistinctWithFilterAndNonDistinctAgg(): Unit = {
+    val sqlQuery = "SELECT d, COUNT(DISTINCT c), COUNT(DISTINCT c) FILTER 
(WHERE a > 0),\n" +
+      "MAX(e), MIN(e) FROM MyTable2 GROUP BY d"
+    util.verifyPlan(sqlQuery)
+  }
+
+  @Test
+  def testMultiDistinctAndNonDistinctAggWithFilter(): Unit = {
+    val sqlQuery = "SELECT d, MAX(e), MAX(e) FILTER (WHERE a < 10), 
COUNT(DISTINCT c),\n" +
+      "COUNT(DISTINCT c) FILTER (WHERE a > 5), COUNT(DISTINCT b) FILTER (WHERE 
b > 3)\n" +
+      "FROM MyTable2 GROUP BY d"
+    util.verifyPlan(sqlQuery)
+  }
+
 
 Review comment:
   actually, It's better to extract a common test case base named 
`DistinctAggregateTestBase` (like `AggregateReduceGroupingTestBase`)

----------------------------------------------------------------
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

Reply via email to