You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2022/01/21 05:53:32 UTC

[GitHub] [druid] kfaraz commented on a change in pull request #12182: Change default value of druid.sql.planner.useGroupingSetForExactDistinct in config files

kfaraz commented on a change in pull request #12182:
URL: https://github.com/apache/druid/pull/12182#discussion_r789379051



##########
File path: sql/src/test/java/org/apache/druid/sql/calcite/CalciteQueryTest.java
##########
@@ -2143,6 +2143,93 @@ public void testHavingOnExactCountDistinct() throws Exception
     );
   }
 
+  @Test
+  public void testExactCountDistinctWithFilter() throws Exception
+  {
+
+    final String sqlQuery = "SELECT COUNT(DISTINCT foo.dim1) FILTER(WHERE foo.cnt = 1), SUM(foo.cnt) FROM druid.foo";
+    // When useApproximateCountDistinct=true and useGroupingSetForExactDistinct=false, planning fails due
+    // to a bug in the Calcite's rule (AggregateExpandDistinctAggregatesRule)
+    try {
+      testQuery(
+          PLANNER_CONFIG_NO_HLL, // Enable exact count distinct
+          sqlQuery,
+          CalciteTests.REGULAR_USER_AUTH_RESULT,
+          ImmutableList.of(),
+          ImmutableList.of()
+      );
+    }
+    catch (RuntimeException e) {
+      Assert.assertTrue(e.getMessage().contains("Error while applying rule AggregateExpandDistinctAggregatesRule"));

Review comment:
       If the above try does not throw an exception, this assertion will never be made.
   You could
   - either break the positive and negative cases into two separate methods and use expected exception
   - or verify the positive case first and then verify the negative case
   
   In both of the above, you could use `assertThrows` or use `@Test(expected = ...)`.
   You could also use try catch but the test should ensure that the exception is always thrown.




-- 
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: commits-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org