feiniaofeiafei opened a new pull request, #70499: URL: https://github.com/apache/doris/pull/70499
### Background Nereids initially allows a cast between aggregate states with the same function name and argument count. During rewriting, a state producer such as `avg_state(i)` can cast its raw input and rebuild its state. A combine aggregate or a slot holding its output keeps its original signature. ### What problem does this PR solve? Issue Number: None Related PR: #66942 (introduced the combine combinator and its coercion flag) PR Type: Refactor Problem Summary: `AggStateType` carried a producer-specific flag so that combine casts could fail during binding. Remove the flag and validate the actual state type after the opportunity to rewrite its producer. Fast VALUES planning and load expression translation now perform the final check as well. ### Details - **Moves vs. logic changes:** Remove the combine-specific constructor parameter, binding check and error. Reuse the bound-cast validator in load translation. Apply the final check to single rows and to constant rows held inside a VALUES union. - **Behavior change:** Incompatible combine casts now reach the final cast check and report the source and target types in the ordinary `cannot cast` error. Matching combine states pass. A compatible state producer can still widen its input. - **Compatibility:** FE planning change. No changes to catalog, wire or storage formats. - **Performance impact:** The fast VALUES expression rewrite also visits union constant rows. Performance was not benchmarked. - **Rollback:** Revert this commit. ### Testing - Ran `./run-fe-ut.sh --run 'CombineCombinatorTest,StateCombinatorTest,CheckCastTest,ExplainInsertCommandTest'` in the local worktree. All 57 tests passed. - Checked compatible and incompatible `INSERT SELECT` combine states, and final cast validation for single-row and multi-row VALUES in both fast planners. - FE Checkstyle reported zero violations. Updated the expected error in the AVG regression suite. The cluster regression suite was not run locally. ### Release note Casting incompatible aggregate combine states reports the standard FE cast error with both types. ### Check List (For Author) - Behavior changed: Yes (see Details) - Does this need documentation: No - Pre-submission status: Partially verified: FE tests and Checkstyle passed. Cluster regression coverage is pending. ### AI Disclosure - Tool: OpenAI Codex (GPT-6) - Generated: Implementation, tests and PR description - Human review: The contributor proposed removing the flag and deferring validation. Review of the final diff is pending. -- 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]
