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

kxiao pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git

commit 9f88e089003fd56a842c205ba97eccd4d0d7dcd8
Author: amory <wangqian...@selectdb.com>
AuthorDate: Thu Oct 19 14:04:50 2023 +0800

    [FIX](func) fix count distinct do not support arr/map/struct (#25483)
---
 .../apache/doris/analysis/FunctionCallExpr.java    |  5 +-
 ...test_count_distinct_with_collection_type.groovy | 67 ++++++++++++++++++++++
 2 files changed, 71 insertions(+), 1 deletion(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java
index e6dd768267c..c3e0bd84381 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java
@@ -1362,7 +1362,10 @@ public class FunctionCallExpr extends Expr {
             // TODO: fix how we equal count distinct.
             fn = getBuiltinFunction(fnName.getFunction(), new Type[0], 
Function.CompareMode.IS_NONSTRICT_SUPERTYPE_OF);
             type = fn.getReturnType();
-
+            if (children.get(0).type.isComplexType()) {
+                throw new AnalysisException("The pattern params of " + fnName 
+ " function can not support "
+                    + children.get(0).type);
+            }
             // Make sure BE doesn't see any TYPE_NULL exprs
             for (int i = 0; i < children.size(); ++i) {
                 if (getChild(i).getType().isNull()) {
diff --git 
a/regression-test/suites/query_p0/sql_functions/aggregate_functions/test_count_distinct_with_collection_type.groovy
 
b/regression-test/suites/query_p0/sql_functions/aggregate_functions/test_count_distinct_with_collection_type.groovy
new file mode 100644
index 00000000000..96cdc229de8
--- /dev/null
+++ 
b/regression-test/suites/query_p0/sql_functions/aggregate_functions/test_count_distinct_with_collection_type.groovy
@@ -0,0 +1,67 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+suite("test_count_distinct_with_collection_type", "p0") {
+    sql """ set enable_nereids_planner=false;"""
+
+    // not support array/map/struct
+    sql " drop table if exists test_collection_type;"
+    sql """ CREATE TABLE IF NOT EXISTS `test_collection_type` (
+      `id` int(11) NULL,
+      `a` array<text> NULL,
+      `m` map<text, int> NULL,
+      `s` STRUCT<f1:INT, f2:VARCHAR(30), f3: DECIMAL> NULL,
+    ) ENGINE=OLAP
+    DUPLICATE KEY(`id`)
+    COMMENT 'OLAP'
+    DISTRIBUTED BY HASH(`id`) BUCKETS 1
+    PROPERTIES (
+    "replication_allocation" = "tag.location.default: 1",
+    "min_load_replica_num" = "-1",
+    "is_being_synced" = "false",
+    "storage_format" = "V2",
+    "light_schema_change" = "true",
+    "disable_auto_compaction" = "false",
+    "enable_single_replica_compaction" = "false"
+    ); """
+
+        test {
+            sql"""select count(distinct a) from test_collection_type;"""
+            check{result, exception, startTime, endTime ->
+                assertTrue(exception != null)
+                logger.info(exception.message)
+            }
+        }
+
+        test {
+            sql"""select count(distinct m) from test_collection_type;"""
+            check{result, exception, startTime, endTime ->
+                assertTrue(exception != null)
+                logger.info(exception.message)
+            }
+        }
+
+        test {
+            sql"""select count(distinct s) from test_collection_type;"""
+            check{result, exception, startTime, endTime ->
+                assertTrue(exception != null)
+                logger.info(exception.message)
+            }
+        }
+
+
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to