feiniaofeiafei opened a new pull request, #70223:
URL: https://github.com/apache/doris/pull/70223
### What problem does this PR solve?
Problem Summary: With `enable_decimal256=true`, `avg(v)` for a
`DECIMAL(18,2)` input returns `DECIMAL(76,4)`, but aggregate-state consumers
could reconstruct a Decimal128 accumulator from the input type alone. This
causes return-type mismatches and makes stored states depend on the consumer's
session settings.
Always retain the FE-selected aggregate result type in AGG_STATE metadata
and use it when constructing BE aggregates. Carry the signature through catalog
persistence, Thrift/Protobuf descriptors, block exchanges, and tablet/segment
metadata. Merge and finalize use the producer's saved result type, and
incompatible serialized-state casts are rejected.
Bind SQL type declarations during analysis rather than parsing. Keep both
regression suites: the AVG suite covers specialized execution paths, while the
broader suite covers seven aggregate functions, both Decimal modes, and
persisted states read under different session settings.
### Release note
Fix Decimal256 aggregate-state result-type mismatches. Aggregate states now
require BE execution version 20 and an explicit result signature in metadata.
Existing states without that signature must be recreated; legacy input-derived
reconstruction is not supported.
### Check List (For Author)
- Test
- [x] Regression test
- Rebuilt FE and ASAN BE, replaced the libraries, and restarted the
dev master cluster.
- `./run-regression-test.sh --run --conf
/tmp/agg-state-regression-conf.groovy -d datatype_p0/agg_state -s
test_decimal256_avg_state,test_decimal_aggregate_state_signatures -parallel 1`
- Result: 2 suites passed, 0 failed, 0 fatal; existing expected output
files matched.
- [x] Unit Test
- Added/updated FE and BE coverage for signatures, serialization,
complex types, version gating, and missing metadata.
- Earlier implementation validation passed 36 FE tests and 80 ASAN BE
tests; the final cleanup was compiled and verified by the two regression suites
above.
- [x] Manual test
- FE build and Checkstyle: `DISABLE_BUILD_UI=ON ./build.sh --fe` (UI
skipped because dev has Node 16).
- ASAN BE build: `BUILD_TYPE=ASAN ./build.sh --be -j16`.
- Generated 16 segment fixtures using the test generator; decoded
comparison confirmed unchanged data pages, with only result signatures and V3
metadata lengths changing.
- clang-format 16 and diff checks passed.
- Behavior changed:
- [x] Yes. All aggregate states retain their producer result type;
states missing result metadata are rejected.
- Does this need documentation?
- [x] No. SQL syntax is unchanged.
### Check List (For Reviewer who merge this PR)
- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label
--
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]