Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions be/src/vec/aggregate_functions/aggregate_function_uniq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ AggregateFunctionPtr create_aggregate_function_uniq(const std::string& name,
} else if (which.is_decimal64()) {
return creator_without_type::create<AggregateFunctionUniq<Decimal64, Data<Int64>>>(
argument_types, result_is_nullable);
} else if (which.is_decimal128i()) {
return creator_without_type::create<AggregateFunctionUniq<Decimal128I, Data<Int128>>>(
argument_types, result_is_nullable);
} else if (which.is_decimal128() || which.is_decimal128i()) {
return creator_without_type::create<AggregateFunctionUniq<Decimal128, Data<Int128>>>(
argument_types, result_is_nullable);
Expand Down
11 changes: 11 additions & 0 deletions regression-test/data/correctness_p0/test_distinct_agg.out
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !distinct_1 --

-- !select1 --
本日

-- !multi_distinct_1 --
2 2

-- !multi_distinct_2 --
369 1145

-- !multi_distinct_3 --
184.5 572.5

44 changes: 43 additions & 1 deletion regression-test/suites/correctness_p0/test_distinct_agg.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ suite("test_distinct_agg") {
result([['1', '2023-01-10', 1L]])
}

sql '''SELECT `b`.`dt` AS `dt`
qt_distinct_1 '''SELECT `b`.`dt` AS `dt`
FROM
(SELECT `dt`AS `dt`,
count(DISTINCT `role_id`) AS `pay_role`,
Expand Down Expand Up @@ -117,4 +117,46 @@ suite("test_distinct_agg") {
sql 'drop view if exists dim_v2'
sql 'drop view if exists dim_v3'
sql 'drop table if exists test_distinct_agg_t'

sql "drop table if exists multi_distinct_agg_tab;"

sql """
CREATE TABLE `multi_distinct_agg_tab` (
`k1` bigint(20) NULL,
`k2` varchar(20) NULL,
`d1` DECIMAL(18, 0) NULL,
`d2` DECIMAL(38, 0) NULL
) ENGINE = OLAP DUPLICATE KEY(`k1`) DISTRIBUTED BY HASH(`k1`) BUCKETS 2 PROPERTIES (
"replication_allocation" = "tag.location.default: 1"
);
"""

sql """
INSERT INTO
`multi_distinct_agg_tab` (`k1`, `k2`, `d1`, `d2`)
VALUES (1, 'aaa', 123, 356),(2, 'bbb', 123, 789), (3, 'ccc', 246, 789);
"""
sql "sync"

qt_multi_distinct_1 """
select
count(distinct d1),
count(distinct d2)
from
multi_distinct_agg_tab;
"""
qt_multi_distinct_2 """
select
sum(distinct d1),
sum(distinct d2)
from
multi_distinct_agg_tab;
"""
qt_multi_distinct_3 """
select
avg(distinct d1),
avg(distinct d2)
from
multi_distinct_agg_tab;
"""
}