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

panxiaolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 70ae9fa4339 [Chore](agg) add creator_with_type_list and 
any_value/ndv/avg/avg_weighted/min/max case (#54302)
70ae9fa4339 is described below

commit 70ae9fa43396fd6b259e628549ae916a7c8e2609
Author: Pxl <[email protected]>
AuthorDate: Tue Aug 5 14:55:43 2025 +0800

    [Chore](agg) add creator_with_type_list and 
any_value/ndv/avg/avg_weighted/min/max case (#54302)
    
    add creator_with_type_list and any_value/ndv/avg/avg_weighted/min/max case
---
 .../aggregate_function_approx_count_distinct.cpp   |  16 ++-
 .../aggregate_functions/aggregate_function_avg.cpp |  13 ++-
 be/src/vec/aggregate_functions/helpers.h           |  93 +++++++++++++++++
 .../aggregate/support_type/any_value/any_value.out | Bin 0 -> 910 bytes
 .../query_p0/aggregate/support_type/avg/avg.out    | Bin 0 -> 463 bytes
 .../support_type/avg_weighted/avg_weighted.out     | Bin 0 -> 126 bytes
 .../query_p0/aggregate/support_type/max/max.out    | Bin 0 -> 731 bytes
 .../query_p0/aggregate/support_type/min/min.out    | Bin 0 -> 724 bytes
 .../query_p0/aggregate/support_type/ndv/ndv.out    | Bin 0 -> 442 bytes
 .../support_type/any_value/any_value.groovy        | 105 +++++++++++++++++++
 .../query_p0/aggregate/support_type/avg/avg.groovy |  66 ++++++++++++
 .../support_type/avg_weighted/avg_weighted.groovy  |  46 +++++++++
 .../query_p0/aggregate/support_type/max/max.groovy |  89 ++++++++++++++++
 .../query_p0/aggregate/support_type/min/min.groovy | 113 +++++++++++++++++++++
 .../query_p0/aggregate/support_type/ndv/ndv.groovy |  84 +++++++++++++++
 15 files changed, 613 insertions(+), 12 deletions(-)

diff --git 
a/be/src/vec/aggregate_functions/aggregate_function_approx_count_distinct.cpp 
b/be/src/vec/aggregate_functions/aggregate_function_approx_count_distinct.cpp
index 72a1d70dc84..3e9a346385d 100644
--- 
a/be/src/vec/aggregate_functions/aggregate_function_approx_count_distinct.cpp
+++ 
b/be/src/vec/aggregate_functions/aggregate_function_approx_count_distinct.cpp
@@ -17,7 +17,7 @@
 
 #include "vec/aggregate_functions/aggregate_function_approx_count_distinct.h"
 
-#include "common/status.h"
+#include "runtime/define_primitive_type.h"
 #include "vec/aggregate_functions/helpers.h"
 #include "vec/data_types/data_type.h"
 
@@ -27,14 +27,12 @@ namespace doris::vectorized {
 AggregateFunctionPtr create_aggregate_function_approx_count_distinct(
         const std::string& name, const DataTypes& argument_types, const bool 
result_is_nullable,
         const AggregateFunctionAttr& attr) {
-    auto res = creator_with_any::create<AggregateFunctionApproxCountDistinct>(
-            argument_types, result_is_nullable, attr);
-    if (!res) {
-        throw Exception(
-                ErrorCode::NOT_IMPLEMENTED_ERROR,
-                "Unsupported type for approx_count_distinct: " + 
argument_types[0]->get_name());
-    }
-    return res;
+    return creator_with_type_list<
+            TYPE_BOOLEAN, TYPE_TINYINT, TYPE_SMALLINT, TYPE_INT, TYPE_BIGINT, 
TYPE_LARGEINT,
+            TYPE_FLOAT, TYPE_DOUBLE, TYPE_DECIMAL32, TYPE_DECIMAL64, 
TYPE_DECIMAL128I,
+            TYPE_DECIMALV2, TYPE_DECIMAL256, TYPE_VARCHAR, TYPE_DATEV2, 
TYPE_DATETIMEV2, TYPE_IPV4,
+            
TYPE_IPV6>::create<AggregateFunctionApproxCountDistinct>(argument_types,
+                                                                     
result_is_nullable, attr);
 }
 
 void 
register_aggregate_function_approx_count_distinct(AggregateFunctionSimpleFactory&
 factory) {
diff --git a/be/src/vec/aggregate_functions/aggregate_function_avg.cpp 
b/be/src/vec/aggregate_functions/aggregate_function_avg.cpp
index aba1e496035..c136262ccf0 100644
--- a/be/src/vec/aggregate_functions/aggregate_function_avg.cpp
+++ b/be/src/vec/aggregate_functions/aggregate_function_avg.cpp
@@ -20,6 +20,7 @@
 
 #include "vec/aggregate_functions/aggregate_function_avg.h"
 
+#include "runtime/define_primitive_type.h"
 #include "vec/aggregate_functions/aggregate_function_simple_factory.h"
 #include "vec/aggregate_functions/helpers.h"
 #include "vec/core/field.h"
@@ -52,11 +53,17 @@ void 
register_aggregate_function_avg(AggregateFunctionSimpleFactory& factory) {
                                            const bool result_is_nullable,
                                            const AggregateFunctionAttr& attr) {
         if (attr.enable_decimal256) {
-            return 
creator_with_type::creator<AggregateFuncAvgDecimal256>(name, types,
+            return creator_with_type_list<
+                    TYPE_TINYINT, TYPE_SMALLINT, TYPE_INT, TYPE_BIGINT, 
TYPE_LARGEINT, TYPE_DOUBLE,
+                    TYPE_DECIMAL32, TYPE_DECIMAL64, TYPE_DECIMAL128I, 
TYPE_DECIMALV2,
+                    
TYPE_DECIMAL256>::creator<AggregateFuncAvgDecimal256>(name, types,
                                                                           
result_is_nullable, attr);
         } else {
-            return creator_with_type::creator<AggregateFuncAvg>(name, types, 
result_is_nullable,
-                                                                attr);
+            return creator_with_type_list<
+                    TYPE_TINYINT, TYPE_SMALLINT, TYPE_INT, TYPE_BIGINT, 
TYPE_LARGEINT, TYPE_DOUBLE,
+                    TYPE_DECIMAL32, TYPE_DECIMAL64, TYPE_DECIMAL128I,
+                    TYPE_DECIMALV2>::creator<AggregateFuncAvg>(name, types, 
result_is_nullable,
+                                                               attr);
         }
     };
     factory.register_function_both("avg", creator);
diff --git a/be/src/vec/aggregate_functions/helpers.h 
b/be/src/vec/aggregate_functions/helpers.h
index 2ba4813cd52..f6fab9e5a45 100644
--- a/be/src/vec/aggregate_functions/helpers.h
+++ b/be/src/vec/aggregate_functions/helpers.h
@@ -360,6 +360,99 @@ using creator_with_decimal_type = 
creator_with_type_base<false, false, true, fal
 using creator_with_type = creator_with_type_base<true, true, true, false, 
false, false>;
 using creator_with_any = creator_with_type_base<true, true, true, true, true, 
true>;
 
+template <int define_index, PrimitiveType... AllowedTypes>
+struct creator_with_type_list_base {
+    template <typename Class, typename... TArgs>
+    static AggregateFunctionPtr create_base(const DataTypes& argument_types,
+                                            const bool result_is_nullable,
+                                            const AggregateFunctionAttr& attr, 
TArgs&&... args) {
+        auto create = [&]<PrimitiveType Ptype>() {
+            return creator_without_type::create<typename Class::template 
T<Ptype>>(
+                    argument_types, result_is_nullable, attr, 
std::forward<TArgs>(args)...);
+        };
+        AggregateFunctionPtr result = nullptr;
+        auto type = argument_types[define_index]->get_primitive_type();
+        if (type == PrimitiveType::TYPE_CHAR || type == 
PrimitiveType::TYPE_STRING ||
+            type == PrimitiveType::TYPE_JSONB) {
+            type = PrimitiveType::TYPE_VARCHAR;
+        }
+
+        (
+                [&] {
+                    if (type == AllowedTypes) {
+                        result = create.template operator()<AllowedTypes>();
+                    }
+                }(),
+                ...);
+
+        return result;
+    }
+
+    template <template <PrimitiveType> class AggregateFunctionTemplate>
+    static AggregateFunctionPtr creator(const std::string& name, const 
DataTypes& argument_types,
+                                        const bool result_is_nullable,
+                                        const AggregateFunctionAttr& attr) {
+        return 
create_base<CurryDirect<AggregateFunctionTemplate>>(argument_types,
+                                                                   
result_is_nullable, attr);
+    }
+
+    template <template <PrimitiveType> class AggregateFunctionTemplate, 
typename... TArgs>
+    static AggregateFunctionPtr create(TArgs&&... args) {
+        return 
create_base<CurryDirect<AggregateFunctionTemplate>>(std::forward<TArgs>(args)...);
+    }
+
+    template <template <typename> class AggregateFunctionTemplate,
+              template <PrimitiveType> class Data>
+    static AggregateFunctionPtr creator(const std::string& name, const 
DataTypes& argument_types,
+                                        const bool result_is_nullable,
+                                        const AggregateFunctionAttr& attr) {
+        return create_base<CurryData<AggregateFunctionTemplate, 
Data>>(argument_types,
+                                                                       
result_is_nullable, attr);
+    }
+
+    template <template <typename> class AggregateFunctionTemplate,
+              template <PrimitiveType> class Data, typename... TArgs>
+    static AggregateFunctionPtr create(TArgs&&... args) {
+        return create_base<CurryData<AggregateFunctionTemplate, Data>>(
+                std::forward<TArgs>(args)...);
+    }
+
+    template <template <typename> class AggregateFunctionTemplate, template 
<typename> class Data,
+              template <PrimitiveType> class Impl>
+    static AggregateFunctionPtr creator(const std::string& name, const 
DataTypes& argument_types,
+                                        const bool result_is_nullable,
+                                        const AggregateFunctionAttr& attr) {
+        return create_base<CurryDataImpl<AggregateFunctionTemplate, Data, 
Impl>>(
+                argument_types, result_is_nullable, attr);
+    }
+
+    template <template <typename> class AggregateFunctionTemplate, template 
<typename> class Data,
+              template <PrimitiveType> class Impl, typename... TArgs>
+    static AggregateFunctionPtr create(TArgs&&... args) {
+        return create_base<CurryDataImpl<AggregateFunctionTemplate, Data, 
Impl>>(
+                std::forward<TArgs>(args)...);
+    }
+
+    template <template <PrimitiveType, typename> class 
AggregateFunctionTemplate,
+              template <PrimitiveType> class Data>
+    static AggregateFunctionPtr creator(const std::string& name, const 
DataTypes& argument_types,
+                                        const bool result_is_nullable,
+                                        const AggregateFunctionAttr& attr) {
+        return create_base<CurryDirectAndData<AggregateFunctionTemplate, 
Data>>(
+                argument_types, result_is_nullable, attr);
+    }
+
+    template <template <PrimitiveType, typename> class 
AggregateFunctionTemplate,
+              template <PrimitiveType> class Data, typename... TArgs>
+    static AggregateFunctionPtr create(TArgs&&... args) {
+        return create_base<CurryDirectAndData<AggregateFunctionTemplate, 
Data>>(
+                std::forward<TArgs>(args)...);
+    }
+};
+
+template <PrimitiveType... AllowedTypes>
+using creator_with_type_list = creator_with_type_list_base<0, AllowedTypes...>;
+
 } // namespace  doris::vectorized
 
 #include "common/compile_check_end.h"
diff --git 
a/regression-test/data/query_p0/aggregate/support_type/any_value/any_value.out 
b/regression-test/data/query_p0/aggregate/support_type/any_value/any_value.out
new file mode 100644
index 00000000000..f243c3bc91d
Binary files /dev/null and 
b/regression-test/data/query_p0/aggregate/support_type/any_value/any_value.out 
differ
diff --git a/regression-test/data/query_p0/aggregate/support_type/avg/avg.out 
b/regression-test/data/query_p0/aggregate/support_type/avg/avg.out
new file mode 100644
index 00000000000..a8747803253
Binary files /dev/null and 
b/regression-test/data/query_p0/aggregate/support_type/avg/avg.out differ
diff --git 
a/regression-test/data/query_p0/aggregate/support_type/avg_weighted/avg_weighted.out
 
b/regression-test/data/query_p0/aggregate/support_type/avg_weighted/avg_weighted.out
new file mode 100644
index 00000000000..f7365ee6724
Binary files /dev/null and 
b/regression-test/data/query_p0/aggregate/support_type/avg_weighted/avg_weighted.out
 differ
diff --git a/regression-test/data/query_p0/aggregate/support_type/max/max.out 
b/regression-test/data/query_p0/aggregate/support_type/max/max.out
new file mode 100644
index 00000000000..01e6a911dd0
Binary files /dev/null and 
b/regression-test/data/query_p0/aggregate/support_type/max/max.out differ
diff --git a/regression-test/data/query_p0/aggregate/support_type/min/min.out 
b/regression-test/data/query_p0/aggregate/support_type/min/min.out
new file mode 100644
index 00000000000..11847e951e8
Binary files /dev/null and 
b/regression-test/data/query_p0/aggregate/support_type/min/min.out differ
diff --git a/regression-test/data/query_p0/aggregate/support_type/ndv/ndv.out 
b/regression-test/data/query_p0/aggregate/support_type/ndv/ndv.out
new file mode 100644
index 00000000000..d4e74681626
Binary files /dev/null and 
b/regression-test/data/query_p0/aggregate/support_type/ndv/ndv.out differ
diff --git 
a/regression-test/suites/query_p0/aggregate/support_type/any_value/any_value.groovy
 
b/regression-test/suites/query_p0/aggregate/support_type/any_value/any_value.groovy
new file mode 100644
index 00000000000..68df1a9b57d
--- /dev/null
+++ 
b/regression-test/suites/query_p0/aggregate/support_type/any_value/any_value.groovy
@@ -0,0 +1,105 @@
+// 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("any_value") {
+    sql "set enable_decimal256 = true;"
+    sql """
+        drop table if exists d_table;
+    """
+    
+    sql """
+    create table d_table (
+        k1 int null,
+        k2 int not null,
+        k3 bigint null,
+        k4 varchar(100) null,
+        col_boolean boolean null,
+        col_tinyint tinyint null,
+        col_smallint smallint null,
+        col_int int null,
+        col_bigint bigint null,
+        col_largeint largeint null,
+        col_float float null,
+        col_double double null,
+        col_char char(10) null,
+        col_varchar varchar(100) null,
+        col_string string null,
+        col_date date null,
+        col_datetime datetime null,
+        col_decimal32 decimal(9,2) null,
+        col_decimal64 decimal(18,4) null,
+        col_decimal128 decimal(38,8) null,
+        col_decimal256 decimal(76,8) null,
+        col_ipv4 ipv4 null,
+        col_ipv6 ipv6 null,
+        col_array array<int> null,
+        col_map map<string, int> null,
+        col_struct struct<name:string, age:int> null,
+        col_bitmap bitmap not null,
+        col_hll hll not null,
+        col_quantile_state quantile_state not null
+        )
+        duplicate key (k1,k2,k3)
+        distributed BY hash(k1) buckets 3
+        properties("replication_num" = "1");
+    """
+    
+    // 插入测试数据
+    sql """
+    insert into d_table values 
+        (1, 1, 1, 'test1', 
+         true, 100, 10000, 1000000, 10000000000, 100000000000000000000,
+         3.14, 2.718281828,
+         'char1', 'varchar1', 'string1',
+         '2023-01-01', '2023-01-01 12:00:00',
+         123.45, 12345.6789, 123456789.12345678, 
123456789123456789123456789123456789123456789123456789123456789.12345678,
+         '192.168.1.1', '2001:db8::1',
+         [1,2,3], {'key1':100, 'key2':200}, named_struct('name', 'John', 
'age', 30),
+         to_bitmap(1), hll_hash(1), to_quantile_state(1, 2048))
+    """
+    
+    qt_sql_boolean """select any_value(col_boolean) from d_table;"""
+    qt_sql_tinyint """select any_value(col_tinyint) from d_table;"""
+    qt_sql_smallint """select any_value(col_smallint) from d_table;"""
+    qt_sql_int """select any_value(col_int) from d_table;"""
+    qt_sql_bigint """select any_value(col_bigint) from d_table;"""
+    qt_sql_largeint """select any_value(col_largeint) from d_table;"""
+    qt_sql_float """select any_value(col_float) from d_table;"""
+    qt_sql_double """select any_value(col_double) from d_table;"""
+
+    qt_sql_char """select any_value(col_char) from d_table;"""
+    qt_sql_varchar """select any_value(col_varchar) from d_table;"""
+    qt_sql_string """select any_value(col_string) from d_table;"""
+
+    qt_sql_date """select any_value(col_date) from d_table;"""
+    qt_sql_datetime """select any_value(col_datetime) from d_table;"""
+
+    qt_sql_decimal32 """select any_value(col_decimal32) from d_table;"""
+    qt_sql_decimal64 """select any_value(col_decimal64) from d_table;"""
+    qt_sql_decimal128 """select any_value(col_decimal128) from d_table;"""
+    qt_sql_decimal256 """select any_value(col_decimal256) from d_table;"""
+
+    qt_sql_ipv4 """select any_value(col_ipv4) from d_table;"""
+    qt_sql_ipv6 """select any_value(col_ipv6) from d_table;"""
+
+    qt_sql_array """select any_value(col_array) from d_table;"""
+    qt_sql_map """select any_value(col_map) from d_table;"""
+    qt_sql_struct """select any_value(col_struct) from d_table;"""
+    qt_sql_bitmap """select bitmap_to_string(any_value(col_bitmap)) from 
d_table;"""
+    qt_sql_hll """select hll_cardinality(any_value(col_hll)) from d_table;"""
+    qt_sql_quantile_state """select 
QUANTILE_PERCENT(any_value(col_quantile_state), 0.5) from d_table;"""
+}
\ No newline at end of file
diff --git 
a/regression-test/suites/query_p0/aggregate/support_type/avg/avg.groovy 
b/regression-test/suites/query_p0/aggregate/support_type/avg/avg.groovy
new file mode 100644
index 00000000000..c3e0b093cb5
--- /dev/null
+++ b/regression-test/suites/query_p0/aggregate/support_type/avg/avg.groovy
@@ -0,0 +1,66 @@
+// 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("avg") {
+    sql "set enable_decimal256 = true;"
+    sql """
+        drop table if exists d_table;
+    """
+    
+    sql """
+    create table d_table (
+        k1 int null,
+        k2 int not null,
+        k3 bigint null,
+        k4 varchar(100) null,
+        col_tinyint tinyint null,
+        col_smallint smallint null,
+        col_int int null,
+        col_bigint bigint null,
+        col_largeint largeint null,
+        col_double double null,
+        col_decimal32 decimal(9,2) null,
+        col_decimal64 decimal(18,4) null,
+        col_decimal128 decimal(38,8) null,
+        col_decimal256 decimal(76,8) null
+        )
+        duplicate key (k1,k2,k3)
+        distributed BY hash(k1) buckets 3
+        properties("replication_num" = "1");
+    """
+    
+    // 插入测试数据
+    sql """
+    insert into d_table values 
+        (1, 1, 1, 'test1', 
+         100, 10000, 1000000, 10000000000, 100000000000000000000,
+         2.718281828,
+         123.45, 12345.6789, 123456789.12345678, 
123456789123456789123456789123456789123456789123456789123456789.12345678)
+    """
+    
+    qt_sql_tinyint """select avg(col_tinyint) from d_table;"""
+    qt_sql_smallint """select avg(col_smallint) from d_table;"""
+    qt_sql_int """select avg(col_int) from d_table;"""
+    qt_sql_bigint """select avg(col_bigint) from d_table;"""
+    qt_sql_largeint """select avg(col_largeint) from d_table;"""
+    qt_sql_double """select avg(col_double) from d_table;"""
+
+    qt_sql_decimal32 """select avg(col_decimal32) from d_table;"""
+    qt_sql_decimal64 """select avg(col_decimal64) from d_table;"""
+    qt_sql_decimal128 """select avg(col_decimal128) from d_table;"""
+    qt_sql_decimal256 """select avg(col_decimal256) from d_table;"""
+}
\ No newline at end of file
diff --git 
a/regression-test/suites/query_p0/aggregate/support_type/avg_weighted/avg_weighted.groovy
 
b/regression-test/suites/query_p0/aggregate/support_type/avg_weighted/avg_weighted.groovy
new file mode 100644
index 00000000000..f49adef5d8c
--- /dev/null
+++ 
b/regression-test/suites/query_p0/aggregate/support_type/avg_weighted/avg_weighted.groovy
@@ -0,0 +1,46 @@
+// 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("avg_weighted") {
+    sql "set enable_decimal256 = true;"
+    sql """
+        drop table if exists d_table;
+    """
+    
+    sql """
+    create table d_table (
+        k1 int null,
+        k2 int not null,
+        k3 bigint null,
+        k4 varchar(100) null,
+        col_double double null,
+        weight_double double null
+        )
+        duplicate key (k1,k2,k3)
+        distributed BY hash(k1) buckets 3
+        properties("replication_num" = "1");
+    """
+    
+    // 插入测试数据
+    sql """
+    insert into d_table values 
+        (1, 1, 1, 'test1', 
+         2.718281828, 1.0)
+    """
+    
+    qt_sql_double """select avg_weighted(col_double, weight_double) from 
d_table;"""
+}
\ No newline at end of file
diff --git 
a/regression-test/suites/query_p0/aggregate/support_type/max/max.groovy 
b/regression-test/suites/query_p0/aggregate/support_type/max/max.groovy
new file mode 100644
index 00000000000..c6b563d2261
--- /dev/null
+++ b/regression-test/suites/query_p0/aggregate/support_type/max/max.groovy
@@ -0,0 +1,89 @@
+// 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("max") {
+    sql "set enable_decimal256 = true;"
+    sql """
+        drop table if exists d_table;
+    """
+    
+    sql """
+    create table d_table (
+        k1 int null,
+        k2 int not null,
+        k3 bigint null,
+        k4 varchar(100) null,
+        col_boolean boolean null,
+        col_tinyint tinyint null,
+        col_smallint smallint null,
+        col_int int null,
+        col_bigint bigint null,
+        col_largeint largeint null,
+        col_float float null,
+        col_double double null,
+        col_char char(10) null,
+        col_varchar varchar(100) null,
+        col_string string null,
+        col_date date null,
+        col_datetime datetime null,
+        col_decimal32 decimal(9,2) null,
+        col_decimal64 decimal(18,4) null,
+        col_decimal128 decimal(38,8) null,
+        col_decimal256 decimal(76,8) null,
+        col_ipv4 ipv4 null,
+        col_ipv6 ipv6 null
+        )
+        duplicate key (k1,k2,k3)
+        distributed BY hash(k1) buckets 3
+        properties("replication_num" = "1");
+    """
+    
+    sql """
+    insert into d_table values 
+        (1, 1, 1, 'test1', 
+         true, 100, 10000, 1000000, 10000000000, 100000000000000000000,
+         3.14, 2.718281828,
+         'char1', 'varchar1', 'string1',
+         '2023-01-01', '2023-01-01 12:00:00',
+         123.45, 12345.6789, 123456789.12345678, 
123456789123456789123456789123456789123456789123456789123456789.12345678,
+         '192.168.1.1', '2001:db8::1')
+    """
+    
+    qt_max_boolean """select max(col_boolean) from d_table;"""
+    qt_max_tinyint """select max(col_tinyint) from d_table;"""
+    qt_max_smallint """select max(col_smallint) from d_table;"""
+    qt_max_int """select max(col_int) from d_table;"""
+    qt_max_bigint """select max(col_bigint) from d_table;"""
+    qt_max_largeint """select max(col_largeint) from d_table;"""
+    qt_max_float """select max(col_float) from d_table;"""
+    qt_max_double """select max(col_double) from d_table;"""
+
+    qt_max_char """select max(col_char) from d_table;"""
+    qt_max_varchar """select max(col_varchar) from d_table;"""
+    qt_max_string """select max(col_string) from d_table;"""
+
+    qt_max_date """select max(col_date) from d_table;"""
+    qt_max_datetime """select max(col_datetime) from d_table;"""
+
+    qt_max_decimal32 """select max(col_decimal32) from d_table;"""
+    qt_max_decimal64 """select max(col_decimal64) from d_table;"""
+    qt_max_decimal128 """select max(col_decimal128) from d_table;"""
+    qt_max_decimal256 """select max(col_decimal256) from d_table;"""
+
+    qt_max_ipv4 """select max(col_ipv4) from d_table;"""
+    qt_max_ipv6 """select max(col_ipv6) from d_table;"""
+}
\ No newline at end of file
diff --git 
a/regression-test/suites/query_p0/aggregate/support_type/min/min.groovy 
b/regression-test/suites/query_p0/aggregate/support_type/min/min.groovy
new file mode 100644
index 00000000000..b5fd8ff4b59
--- /dev/null
+++ b/regression-test/suites/query_p0/aggregate/support_type/min/min.groovy
@@ -0,0 +1,113 @@
+// 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("min") {
+    sql "set enable_decimal256 = true;"
+    sql """
+        drop table if exists d_table;
+    """
+    
+    sql """
+    create table d_table (
+        k1 int null,
+        k2 int not null,
+        k3 bigint null,
+        k4 varchar(100) null,
+        col_boolean boolean null,
+        col_tinyint tinyint null,
+        col_smallint smallint null,
+        col_int int null,
+        col_bigint bigint null,
+        col_largeint largeint null,
+        col_float float null,
+        col_double double null,
+        col_char char(10) null,
+        col_varchar varchar(100) null,
+        col_string string null,
+        col_date date null,
+        col_datetime datetime null,
+        col_decimal32 decimal(9,2) null,
+        col_decimal64 decimal(18,4) null,
+        col_decimal128 decimal(38,8) null,
+        col_decimal256 decimal(76,8) null,
+        col_ipv4 ipv4 null,
+        col_ipv6 ipv6 null
+        )
+        duplicate key (k1,k2,k3)
+        distributed BY hash(k1) buckets 3
+        properties("replication_num" = "1");
+    """
+    
+    // 插入测试数据
+    sql """
+    insert into d_table values 
+        (1, 1, 1, 'test1', 
+         true, 100, 10000, 1000000, 10000000000, 100000000000000000000,
+         3.14, 2.718281828,
+         'char1', 'varchar1', 'string1',
+         '2023-01-01', '2023-01-01 12:00:00',
+         123.45, 12345.6789, 123456789.12345678, 
123456789123456789123456789123456789123456789123456789123456789.12345678,
+         '192.168.1.1', '2001:db8::1')
+    """
+    
+    sql """
+    insert into d_table values 
+        (2, 2, 2, 'test2', 
+         false, 50, 5000, 500000, 5000000000, 50000000000000000000,
+         2.71, 3.141592653,
+         'char2', 'varchar2', 'string2',
+         '2023-02-01', '2023-02-01 13:30:00',
+         234.56, 23456.7890, 234567890.23456789, 
234567890234567890234567890234567890234567890234567890234567890.23456789,
+         '10.0.0.1', '2001:db8::2')
+    """
+    
+    sql """
+    insert into d_table values 
+        (3, 3, 3, 'test3', 
+         true, 75, 7500, 750000, 7500000000, 75000000000000000000,
+         1.41, 1.732050808,
+         'char3', 'varchar3', 'string3',
+         '2023-03-01', '2023-03-01 14:45:00',
+         345.67, 34567.8901, 345678901.34567890, 
345678901345678901345678901345678901345678901345678901345678901.34567890,
+         '172.16.0.1', '2001:db8::3')
+    """
+    
+    // 测试 min 函数对各种数据类型的支持
+    qt_min_boolean """select min(col_boolean) from d_table;"""
+    qt_min_tinyint """select min(col_tinyint) from d_table;"""
+    qt_min_smallint """select min(col_smallint) from d_table;"""
+    qt_min_int """select min(col_int) from d_table;"""
+    qt_min_bigint """select min(col_bigint) from d_table;"""
+    qt_min_largeint """select min(col_largeint) from d_table;"""
+    qt_min_float """select min(col_float) from d_table;"""
+    qt_min_double """select min(col_double) from d_table;"""
+
+    qt_min_char """select min(col_char) from d_table;"""
+    qt_min_varchar """select min(col_varchar) from d_table;"""
+    qt_min_string """select min(col_string) from d_table;"""
+
+    qt_min_date """select min(col_date) from d_table;"""
+    qt_min_datetime """select min(col_datetime) from d_table;"""
+
+    qt_min_decimal32 """select min(col_decimal32) from d_table;"""
+    qt_min_decimal64 """select min(col_decimal64) from d_table;"""
+    qt_min_decimal128 """select min(col_decimal128) from d_table;"""
+    qt_min_decimal256 """select min(col_decimal256) from d_table;"""
+
+    qt_min_ipv4 """select min(col_ipv4) from d_table;"""
+    qt_min_ipv6 """select min(col_ipv6) from d_table;"""
+}
\ No newline at end of file
diff --git 
a/regression-test/suites/query_p0/aggregate/support_type/ndv/ndv.groovy 
b/regression-test/suites/query_p0/aggregate/support_type/ndv/ndv.groovy
new file mode 100644
index 00000000000..f57dc9ea84b
--- /dev/null
+++ b/regression-test/suites/query_p0/aggregate/support_type/ndv/ndv.groovy
@@ -0,0 +1,84 @@
+// 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("ndv") {
+    sql "set enable_decimal256 = true;"
+    sql """
+        drop table if exists d_table;
+    """
+    
+    sql """
+    create table d_table (
+        k1 int null,
+        k2 int not null,
+        k3 bigint null,
+        k4 varchar(100) null,
+        col_tinyint tinyint null,
+        col_smallint smallint null,
+        col_int int null,
+        col_bigint bigint null,
+        col_largeint largeint null,
+        col_float float null,
+        col_double double null,
+        col_string string null,
+        col_date date null,
+        col_datetime datetime null,
+        col_decimal32 decimal(9,2) null,
+        col_decimal64 decimal(18,4) null,
+        col_decimal128 decimal(38,8) null,
+        col_decimal256 decimal(76,8) null,
+        col_ipv4 ipv4 null,
+        col_ipv6 ipv6 null
+        )
+        duplicate key (k1,k2,k3)
+        distributed BY hash(k1) buckets 3
+        properties("replication_num" = "1");
+    """
+    
+    // 插入测试数据
+    sql """
+    insert into d_table values 
+        (1, 1, 1, 'test1', 
+         100, 10000, 1000000, 10000000000, 100000000000000000000,
+         3.14, 2.718281828,
+         'string1',
+         '2023-01-01', '2023-01-01 12:00:00',
+         123.45, 12345.6789, 123456789.12345678, 
123456789123456789123456789123456789123456789123456789123456789.12345678,
+         '192.168.1.1', '2001:db8::1')
+    """
+    
+    qt_sql_tinyint """select approx_count_distinct(col_tinyint) from 
d_table;"""
+    qt_sql_smallint """select approx_count_distinct(col_smallint) from 
d_table;"""
+    qt_sql_int """select approx_count_distinct(col_int) from d_table;"""
+    qt_sql_bigint """select approx_count_distinct(col_bigint) from d_table;"""
+    qt_sql_largeint """select approx_count_distinct(col_largeint) from 
d_table;"""
+    qt_sql_float """select approx_count_distinct(col_float) from d_table;"""
+    qt_sql_double """select approx_count_distinct(col_double) from d_table;"""
+
+    qt_sql_string """select approx_count_distinct(col_string) from d_table;"""
+
+    qt_sql_date """select approx_count_distinct(col_date) from d_table;"""
+    qt_sql_datetime """select approx_count_distinct(col_datetime) from 
d_table;"""
+
+    qt_sql_decimal32 """select approx_count_distinct(col_decimal32) from 
d_table;"""
+    qt_sql_decimal64 """select approx_count_distinct(col_decimal64) from 
d_table;"""
+    qt_sql_decimal128 """select approx_count_distinct(col_decimal128) from 
d_table;"""
+    qt_sql_decimal256 """select approx_count_distinct(col_decimal256) from 
d_table;"""
+
+    qt_sql_ipv4 """select approx_count_distinct(col_ipv4) from d_table;"""
+    qt_sql_ipv6 """select approx_count_distinct(col_ipv6) from d_table;"""
+}
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]


Reply via email to