feiniaofeiafei opened a new pull request, #70223:
URL: https://github.com/apache/doris/pull/70223

   ### Background
   
   Doris stores intermediate aggregate values in AGG_STATE columns. Readers use 
the aggregate signature to select the matching accumulator and serialized 
layout.
   
   ### What problem does this PR solve?
   
   Issue Number: None
   Related PR: #70499 (upstream aggregate-state cast validation)
   PR Type: Bugfix
   
   Problem Summary:
   
   For the same decimal arguments, the producer can choose Decimal128 or 
Decimal256 based on `enable_decimal256`. Reconstructing a state from its 
arguments can pick a different accumulator. Save the producer's result type 
across FE, BE and storage, and apply legacy inference when an existing column 
has no saved result type. Bind aggregate-state signatures to built-in 
aggregates so a same-name alias cannot change a state’s identity.
   
   ### Details
   
   - **Change map:** FE signature binding, optional Thrift and Protobuf fields, 
and BE type and storage handling. FE and BE unit tests, SQL regressions, and 
segment fixtures cover the signature paths.
   - **Frequency:** Depends on a difference between the accumulator selected by 
the producer and the one inferred by the consumer. The review follow-up covers 
a same-name scalar alias with `prefer_udf_over_builtin=true`.
   - **Root cause:** Argument metadata omits the accumulator precision. The 
signature binder could also select a scalar alias through the ordinary SQL 
function lookup.
   - **Why existing tests missed it:** Aggregate-state tests lacked coverage 
across Decimal256 session changes. UDF precedence tests covered ordinary 
function calls, and existing aggregate-state tests did not combine that setting 
with a same-name alias.
   - **Fix:** Save the resolved result type and use it for state consumers. Use 
built-in aggregate candidates for new declarations and legacy inference, with 
the same argument and overload matching as other function lookups.
   - **Other paths and branches:** New declarations, explicit casts, legacy 
reads, CREATE TABLE LIKE and restore share or preserve the resolved signature. 
The change targets master. The alias-binding defect was found on this PR's 
previous head.
   - **Behavior change:** After a standard BE-first upgrade, explicit result 
signatures work with the existing default BE execution version (19). Existing 
states without a signature remain readable through legacy inference. Writes 
with incompatible signatures are rejected.
   
   ### Testing
   
   - At ba76ffd3a3e all 14 selected FE tests passed. The test-only follow-up 
removes the standalone version 19 declaration case and retains the exact type 
inference and version 19 serialization assertions.
   - FE Checkstyle, clang-format 16 check, BE build hygiene, and whitespace 
checks passed.
   - Built and deployed FE and BE from 135fadb7101 on the dev master cluster. 
Both versioned SQL suites passed: `test_map_agg_v2_versioned_state` and 
`test_restricted_aggregate_versioned_state` (2 passed, 0 failed, 0 skipped).
   - Earlier revisions passed the selected FE cases and the two decimal 
aggregate-state SQL suites. Those runs predate removal of the gate.
   
   ### Release note
   
   Decimal aggregate states retain the producer's result precision across 
session setting changes. Existing states without a saved result signature 
remain readable with legacy inference.
   
   ### Check List (For Author)
   
   - Behavior changed: Yes (see Details)
   - Does this need documentation: No
   - Pre-submission status: Partially verified: the two targeted SQL 
regressions passed. Mixed-binary rolling upgrades and clang-tidy were not 
tested.
   
   ### AI Disclosure
   
   - Tool: OpenAI Codex
   - Generated: Review follow-up code, FE test changes, and description draft.
   - Human review: 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]

Reply via email to