github-actions[bot] commented on code in PR #70223:
URL: https://github.com/apache/doris/pull/70223#discussion_r4675686888
##########
be/src/core/data_type/data_type_factory.cpp:
##########
@@ -762,8 +757,10 @@ DataTypePtr DataTypeFactory::create_data_type(const
TTypeDesc& t, bool is_nullab
}
DCHECK(t.__isset.result_is_nullable);
DCHECK(t.__isset.function_name);
- nested = std::make_shared<DataTypeAggState>(subTypes,
t.result_is_nullable, t.function_name,
- t.be_exec_version);
+ nested = std::make_shared<DataTypeAggState>(
+ subTypes, t.result_is_nullable, t.function_name,
t.be_exec_version,
+ t.agg_state_result_type ?
create_data_type(*t.agg_state_result_type, false)
Review Comment:
[P2] Decode AGG_STATE children in complex result signatures
With `enable_agg_state=true`, `SELECT count(array_agg_state(sum_state(CAST(1
AS int))))` supplies an `ARRAY<AGG_STATE<sum(int)>>` result signature here. The
ARRAY root enters the flat-node reader, whose scalar AGG_STATE child reaches
the primitive factory and throws `Nested type should not reach here AGG_STATE`.
Previously, `array_agg` constructed its state from the complete first argument
and ignored the result hint. Preserve and decode signatures for state children
within complex results, and add this composition as a regression. The existing
nested-state thread's root AGG_STATE example is fixed; this separate
ARRAY-reader branch still fails.
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/types/AggStateType.java:
##########
@@ -86,6 +110,68 @@ public AggStateType(String functionName, List<DataType>
subTypes,
this.returnNullable = returnNullable;
}
+ /** Record a declaration without binding functions or consulting the
session in the parser. */
+ public static AggStateType declaration(String name, List<DataType> inputs,
+ List<Boolean> nullables, boolean returnNullable) {
+ return new AggStateType(name, inputs, nullables, returnNullable);
+ }
+
+ /** Resolve new declarations only; catalog types retain their saved
signatures. */
+ public AggStateType resolveDeclaration() {
+ if (resultType != null) {
+ return this;
+ }
+ AggregateFunction nested = bindNestedAggregate();
Review Comment:
[P2] Resolve inner state declarations before binding the outer signature
For `SELECT CAST(s AS agg_state<any_value(agg_state<sum(int not null)> not
null)>) FROM (SELECT any_value_state(sum_state(CAST(1 AS int))) AS s) t`, this
resolves only the outer ANY_VALUE declaration. Its inner SUM keeps
`resultType=null`, while the producer's inner SUM records BIGINT. The resulting
plan contains `Project(Cast(s, declared ANY_VALUE<SUM<INT>>))` over the
state-producing project; recursive type equality fails and `CheckCast` rejects
the equivalent cast. Producer rewrites leave the same mismatch in the inner SUM
cast. Resolve nested AGG_STATE declarations before binding the outer signature,
and cover nested declarations/casts in tests. This fails during FE analysis,
independently of the descriptor-serialization issue in the earlier thread.
--
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]