Skip to content

Commit 6bc495f

Browse files
branch-3.0: [Bug](agg-state) fix agg state inner type not conversioned #50418 (#50575)
Cherry-picked from #50418 Co-authored-by: Pxl <[email protected]>
1 parent 98c3f03 commit 6bc495f

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

fe/fe-core/src/main/java/org/apache/doris/nereids/types/AggStateType.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ public Type toCatalogDataType() {
104104
return Expr.createAggStateType(functionName, types, subTypeNullables);
105105
}
106106

107+
@Override
108+
public DataType conversion() {
109+
return new AggStateType(functionName, subTypes.stream().map(DataType::conversion).collect(Collectors.toList()),
110+
subTypeNullables);
111+
}
112+
107113
@Override
108114
public boolean acceptsType(DataType other) {
109115
return other instanceof AggStateType;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-- This file is automatically generated. You should know what you did if you want to edit this
2+
-- !select --
3+
30.200000
4+
21.200000
5+
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
suite("test_decimal_sum") {
19+
sql "set enable_agg_state=true"
20+
sql """ DROP TABLE IF EXISTS t01; """
21+
sql """
22+
create table t01(id int, decimal_col agg_state<sum(decimal(20,6))> generic) properties ("replication_num" = "1");
23+
"""
24+
25+
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));
26+
"""
27+
28+
29+
qt_select """ select sum_merge(decimal_col) from t01 group by id order by id;
30+
"""
31+
}

0 commit comments

Comments
 (0)