diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/AggStateType.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/AggStateType.java index 2f704190fef707..290a59acaa8b2f 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/AggStateType.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/AggStateType.java @@ -104,6 +104,12 @@ public Type toCatalogDataType() { return Expr.createAggStateType(functionName, types, subTypeNullables); } + @Override + public DataType conversion() { + return new AggStateType(functionName, subTypes.stream().map(DataType::conversion).collect(Collectors.toList()), + subTypeNullables); + } + @Override public boolean acceptsType(DataType other) { return other instanceof AggStateType; diff --git a/regression-test/data/datatype_p0/agg_state/decimal_sum/test_decimal_sum.out b/regression-test/data/datatype_p0/agg_state/decimal_sum/test_decimal_sum.out new file mode 100644 index 00000000000000..240ed8b30b8cd4 --- /dev/null +++ b/regression-test/data/datatype_p0/agg_state/decimal_sum/test_decimal_sum.out @@ -0,0 +1,5 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !select -- +30.200000 +21.200000 + diff --git a/regression-test/suites/datatype_p0/agg_state/decimal_sum/test_decimal_sum.groovy b/regression-test/suites/datatype_p0/agg_state/decimal_sum/test_decimal_sum.groovy new file mode 100644 index 00000000000000..e8d643d26b9f4e --- /dev/null +++ b/regression-test/suites/datatype_p0/agg_state/decimal_sum/test_decimal_sum.groovy @@ -0,0 +1,31 @@ +// 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_decimal_sum") { + sql "set enable_agg_state=true" + sql """ DROP TABLE IF EXISTS t01; """ + sql """ + create table t01(id int, decimal_col agg_state generic) properties ("replication_num" = "1"); + """ + + sql """insert into t01 values (1, sum_state(10.1)), (1, sum_state(20.1)), (2, sum_state(10.2)), (2, sum_state(11.0)); +""" + + + qt_select """ select sum_merge(decimal_col) from t01 group by id order by id; + """ +}