hello-stephen commented on code in PR #70223:
URL: https://github.com/apache/doris/pull/70223#discussion_r4779124030
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/combinator/StateCombinator.java:
##########
@@ -77,7 +77,8 @@ public StateCombinator(List<Expression> arguments,
AggregateFunction nested) {
this.returnType = new AggStateType(nested.getName(),
arguments.stream().map(ExpressionTrait::getDataType).collect(ImmutableList.toImmutableList()),
arguments.stream().map(ExpressionTrait::nullable).collect(ImmutableList.toImmutableList()),
-
BuiltinAggregateFunctions.INSTANCE.aggFuncNameNullableMap.get(nested.getName()));
+
BuiltinAggregateFunctions.INSTANCE.aggFuncNameNullableMap.get(nested.getName()),
+ nested.getDataType());
Review Comment:
[P2] Coerce SUM arguments before saving its result signature
With an existing `v DECIMAL(76,6)` column created while
`enable_decimal256=true`, disable that setting and run `SELECT sum_state(v)
FROM t`. The retained plan is:
```text
Project(sum_state(v))
Scan(t[v:DECIMAL(76,6)])
```
`nested.getDataType()` now records SUM's narrowed `DECIMAL(38,6)` result,
but `StateCombinator.getSignatures()` still uses the raw
`nested.getSignatures()`, so producer coercion leaves `v` as Decimal256. BE
constructs this saved signature through `DataTypeAggState`, and SUM's
`create_base_with_result_type` throws because the result primitive is narrower
than the input. Before this change, the missing result hint made BE use
Decimal256 for this input. Apply the nested aggregate's computed input casts
before saving both argument and result metadata. `sum0`, multi-distinct SUM and
`_combine` share this path; add a producer regression over an existing
Decimal256 column with the setting disabled.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]