This is an automated email from the ASF dual-hosted git repository.

mbudiu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/calcite.git


The following commit(s) were added to refs/heads/main by this push:
     new 61e6dd1170 [CALCITE-6943] Calcite JDBC adapter for Hive should 
translate APPROX_COUNT_DISTINCT to COUNT DISTINCT
61e6dd1170 is described below

commit 61e6dd11706aed0ee617a251643022b331c7d466
Author: Yu Xu <[email protected]>
AuthorDate: Wed Apr 9 18:16:50 2025 +0800

    [CALCITE-6943] Calcite JDBC adapter for Hive should translate 
APPROX_COUNT_DISTINCT to COUNT DISTINCT
---
 .../main/java/org/apache/calcite/sql/dialect/HiveSqlDialect.java    | 4 ----
 .../java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java  | 6 +++++-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git 
a/core/src/main/java/org/apache/calcite/sql/dialect/HiveSqlDialect.java 
b/core/src/main/java/org/apache/calcite/sql/dialect/HiveSqlDialect.java
index e50229e683..8892ca1cf0 100644
--- a/core/src/main/java/org/apache/calcite/sql/dialect/HiveSqlDialect.java
+++ b/core/src/main/java/org/apache/calcite/sql/dialect/HiveSqlDialect.java
@@ -144,10 +144,6 @@ public HiveSqlDialect(Context context) {
     return false;
   }
 
-  @Override public boolean supportsApproxCountDistinct() {
-    return true;
-  }
-
   @Override public boolean supportsNestedAggregations() {
     return false;
   }
diff --git 
a/core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java 
b/core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java
index 9169aebe48..ffa34ea95f 100644
--- 
a/core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java
+++ 
b/core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java
@@ -8269,6 +8269,9 @@ private void checkLiteral2(String expression, String 
expected) {
     sql.ok(expected);
   }
 
+  /** Test case for
+   * <a 
href="https://issues.apache.org/jira/browse/CALCITE-6943";>[CALCITE-6943]
+   * Calcite JDBC adapter for Hive should translate APPROX_COUNT_DISTINCT to 
COUNT DISTINCT</a>.*/
   @Test void testSelectApproxCountDistinct() {
     final String query = "select approx_count_distinct(\"product_id\") from 
\"product\"";
     final String expectedExact = "SELECT COUNT(DISTINCT \"product_id\")\n"
@@ -8288,9 +8291,10 @@ private void checkLiteral2(String expression, String 
expected) {
     final String expectedPhoenix = expectedApproxQuota;
     final String expectedClickhouse = "SELECT UNIQ(`product_id`)\n"
         + "FROM `foodmart`.`product`";
+    final String expectedHive = "SELECT COUNT(DISTINCT `product_id`)\nFROM 
`foodmart`.`product`";
 
     sql(query).ok(expectedExact)
-        .withHive().ok(expectedApprox)
+        .withHive().ok(expectedHive)
         .withSpark().ok(expectedApprox)
         .withBigQuery().ok(expectedBigQuery)
         .withOracle().ok(expectedApproxQuota)

Reply via email to