From 72c8791336abc8b750a31482d091ca92509c0ac6 Mon Sep 17 00:00:00 2001 From: Adarsh Sanjeev Date: Thu, 20 Jul 2023 14:49:25 +0530 Subject: [PATCH 1/2] Update a comment in Calcite UTs --- .../java/org/apache/druid/sql/calcite/CalciteQueryTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/src/test/java/org/apache/druid/sql/calcite/CalciteQueryTest.java b/sql/src/test/java/org/apache/druid/sql/calcite/CalciteQueryTest.java index 54c8b3607063..62a715f8d57a 100644 --- a/sql/src/test/java/org/apache/druid/sql/calcite/CalciteQueryTest.java +++ b/sql/src/test/java/org/apache/druid/sql/calcite/CalciteQueryTest.java @@ -2333,7 +2333,7 @@ public void testExactCountDistinctWithFilter() { notMsqCompatible(); 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 + // When useApproximateCountDistinct=false and useGroupingSetForExactDistinct=false, planning fails due // to a bug in the Calcite's rule (AggregateExpandDistinctAggregatesRule) try { testQuery( From 1a341c2d3b9a012b49795584f89e0e8c6226eaad Mon Sep 17 00:00:00 2001 From: Adarsh Sanjeev Date: Tue, 25 Jul 2023 14:58:28 +0530 Subject: [PATCH 2/2] Change assert --- .../druid/sql/calcite/CalciteQueryTest.java | 33 +++++++++---------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/sql/src/test/java/org/apache/druid/sql/calcite/CalciteQueryTest.java b/sql/src/test/java/org/apache/druid/sql/calcite/CalciteQueryTest.java index 62a715f8d57a..fa38098606a3 100644 --- a/sql/src/test/java/org/apache/druid/sql/calcite/CalciteQueryTest.java +++ b/sql/src/test/java/org/apache/druid/sql/calcite/CalciteQueryTest.java @@ -2335,24 +2335,21 @@ public void testExactCountDistinctWithFilter() final String sqlQuery = "SELECT COUNT(DISTINCT foo.dim1) FILTER(WHERE foo.cnt = 1), SUM(foo.cnt) FROM druid.foo"; // When useApproximateCountDistinct=false and useGroupingSetForExactDistinct=false, planning fails due // to a bug in the Calcite's rule (AggregateExpandDistinctAggregatesRule) - try { - testQuery( - PLANNER_CONFIG_NO_HLL.withOverrides( - ImmutableMap.of( - PlannerConfig.CTX_KEY_USE_GROUPING_SET_FOR_EXACT_DISTINCT, - "false" - ) - ), // Enable exact count distinct - sqlQuery, - CalciteTests.REGULAR_USER_AUTH_RESULT, - ImmutableList.of(), - ImmutableList.of() - ); - Assert.fail("query execution should fail"); - } - catch (RuntimeException e) { - Assert.assertTrue(e.getMessage().contains("Error while applying rule AggregateExpandDistinctAggregatesRule")); - } + Assert.assertThrows( + RuntimeException.class, + () -> testQuery( + PLANNER_CONFIG_NO_HLL.withOverrides( + ImmutableMap.of( + PlannerConfig.CTX_KEY_USE_GROUPING_SET_FOR_EXACT_DISTINCT, "false", + PlannerConfig.CTX_KEY_USE_APPROXIMATE_COUNT_DISTINCT, false + ) + ), // Enable exact count distinct + sqlQuery, + CalciteTests.REGULAR_USER_AUTH_RESULT, + ImmutableList.of(), + ImmutableList.of() + ) + ); requireMergeBuffers(3); testQuery(