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 42e9f65cdfb [Bug](function) add ndv decimalv2 support (#61546)
42e9f65cdfb is described below

commit 42e9f65cdfb4c3b3275721d18e335e4f86f1830e
Author: Pxl <[email protected]>
AuthorDate: Fri Mar 20 18:12:53 2026 +0800

    [Bug](function) add ndv decimalv2 support (#61546)
    
    This pull request focuses on improving support for the `DECIMALV2` data
    type in aggregate functions and updating related regression tests to
    ensure correctness. The most important changes are grouped below:
    
    ### Aggregate Function Support
    
    * Added `TYPE_DECIMALV2` to the supported types for the
    `approx_count_distinct` aggregate function in
    `aggregate_function_approx_count_distinct.cpp`, enabling this function
    to work with `DECIMALV2` columns.
    
    ### Regression Test Enhancements
    
    * Updated the output in `test_decimalv2.out` to reflect higher precision
    for `DECIMALV2` values, showing results with more decimal places to
    match the new behavior.
    * Added a new test case in `test_decimalv2.groovy` to verify the correct
    behavior of the `ndv` (number of distinct values) aggregate function on
    `DECIMALV2` columns.
---
 .../aggregate_function_approx_count_distinct.cpp   |  5 +-
 .../data/nereids_p0/datatype/test_decimalv2.out    | 59 ++++++++++++----------
 .../nereids_p0/datatype/test_decimalv2.groovy      |  2 +
 3 files changed, 36 insertions(+), 30 deletions(-)

diff --git 
a/be/src/exprs/aggregate/aggregate_function_approx_count_distinct.cpp 
b/be/src/exprs/aggregate/aggregate_function_approx_count_distinct.cpp
index 503bce28af2..314476b2e6e 100644
--- a/be/src/exprs/aggregate/aggregate_function_approx_count_distinct.cpp
+++ b/be/src/exprs/aggregate/aggregate_function_approx_count_distinct.cpp
@@ -29,8 +29,9 @@ AggregateFunctionPtr 
create_aggregate_function_approx_count_distinct(
         const bool result_is_nullable, const AggregateFunctionAttr& attr) {
     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_DECIMAL256, TYPE_VARCHAR, TYPE_DATEV2, TYPE_DATETIMEV2, 
TYPE_IPV4, TYPE_IPV6,
+            TYPE_FLOAT, TYPE_DOUBLE, TYPE_DECIMALV2, TYPE_DECIMAL32, 
TYPE_DECIMAL64,
+            TYPE_DECIMAL128I, TYPE_DECIMAL256, TYPE_VARCHAR, TYPE_DATEV2, 
TYPE_DATETIMEV2,
+            TYPE_IPV4, TYPE_IPV6,
             
TYPE_TIMESTAMPTZ>::create<AggregateFunctionApproxCountDistinct>(argument_types,
                                                                             
result_is_nullable,
                                                                             
attr);
diff --git a/regression-test/data/nereids_p0/datatype/test_decimalv2.out 
b/regression-test/data/nereids_p0/datatype/test_decimalv2.out
index 70c7ed37cbb..7df088d5649 100644
--- a/regression-test/data/nereids_p0/datatype/test_decimalv2.out
+++ b/regression-test/data/nereids_p0/datatype/test_decimalv2.out
@@ -1,52 +1,55 @@
 -- This file is automatically generated. You should know what you did if you 
want to edit this
 -- !sql1 --
-1.230
+1.230000000
 
 -- !sql2 --
 1.230
 
 -- !sql1 --
-1      1.230
-2      2.340
-3      3.450
+1      1.230000000
+2      2.340000000
+3      3.450000000
 
 -- !sql2 --
-1      1.230   1       1.230
-2      2.340   2       2.340
-3      3.450   3       3.450
+1      1.230000000     1       1.230000000
+2      2.340000000     2       2.340000000
+3      3.450000000     3       3.450000000
 
 -- !sql2 --
-1      1.230   1       1.230
-2      2.340   2       2.340
-3      3.450   3       3.450
+1      1.230000000     1       1.230000000
+2      2.340000000     2       2.340000000
+3      3.450000000     3       3.450000000
 
 -- !sql2 --
-1      1.230   1       1.230
-2      2.340   2       2.340
-3      3.450   3       3.450
+1      1.230000000     1       1.230000000
+2      2.340000000     2       2.340000000
+3      3.450000000     3       3.450000000
 
 -- !sql2 --
-1      1.230   1       1.230
-2      2.340   2       2.340
-3      3.450   3       3.450
+1      1.230000000     1       1.230000000
+2      2.340000000     2       2.340000000
+3      3.450000000     3       3.450000000
 
 -- !sql2 --
-1      1.230   1       1.230
-2      2.340   2       2.340
-3      3.450   3       3.450
+1      1.230000000     1       1.230000000
+2      2.340000000     2       2.340000000
+3      3.450000000     3       3.450000000
 
 -- !sql2 --
-1      1.230   1       1.230
-2      2.340   2       2.340
-3      3.450   3       3.450
+1      1.230000000     1       1.230000000
+2      2.340000000     2       2.340000000
+3      3.450000000     3       3.450000000
 
 -- !sql2 --
-1      1.230   1       1.230
-2      2.340   2       2.340
-3      3.450   3       3.450
+1      1.230000000     1       1.230000000
+2      2.340000000     2       2.340000000
+3      3.450000000     3       3.450000000
 
 -- !sql2 --
-1      1.230   1       1.230
-2      2.340   2       2.340
-3      3.450   3       3.450
+1      1.230000000     1       1.230000000
+2      2.340000000     2       2.340000000
+3      3.450000000     3       3.450000000
+
+-- !test --
+3
 
diff --git a/regression-test/suites/nereids_p0/datatype/test_decimalv2.groovy 
b/regression-test/suites/nereids_p0/datatype/test_decimalv2.groovy
index 3bdab1ccd51..6b689d7f152 100644
--- a/regression-test/suites/nereids_p0/datatype/test_decimalv2.groovy
+++ b/regression-test/suites/nereids_p0/datatype/test_decimalv2.groovy
@@ -84,5 +84,7 @@ suite("test_decimalv2") {
     sql " set runtime_filter_type = 8; "
     qt_sql2 "select * from ${tbName} a, ${tbName} b WHERE a.c2 = b.c2 ORDER BY 
a.c0"
 
+    qt_test "select ndv(c2) from ${tbName}; "
+
     sql "DROP TABLE ${tbName}"
 }


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

Reply via email to