cshuo commented on a change in pull request #1741: [CALCITE-3721] Filter of 
distinct aggregate call is lost after applyi…
URL: https://github.com/apache/calcite/pull/1741#discussion_r365494265
 
 

 ##########
 File path: core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java
 ##########
 @@ -1474,6 +1474,27 @@ private void 
basePushFilterPastAggWithGroupingSets(boolean unchanged)
     sql(sql).with(program).check();
   }
 
+  @Test public void testDistinctWithFilterWithoutGroupBy() {
+    final String sql = "SELECT SUM(comm), COUNT(DISTINCT comm),\n"
+        + "COUNT(DISTINCT sal) FILTER (WHERE sal > 1000)\n"
+        + "FROM emp";
+    HepProgram program = new HepProgramBuilder()
+        .addRuleInstance(AggregateExpandDistinctAggregatesRule.INSTANCE)
+        .build();
+    sql(sql).with(program).check();
+  }
+
+  @Test public void testDistinctWithFilterAndGroupBy() {
+    final String sql = "SELECT deptno, SUM(comm), COUNT(DISTINCT comm),\n"
+        + "COUNT(DISTINCT sal) FILTER (WHERE sal > 1000)\n"
 
 Review comment:
   Hi, vlsi, the mininal reproducible case is there exists two aggregation 
call, one is distinct aggregate call with filter, the other can be distinct agg 
call or not. I've update the JIRA description with a comprehensible case. And 
the test cases here can be simplified a little actually.

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