feiniaofeiafei opened a new pull request, #67758:
URL: https://github.com/apache/doris/pull/67758
### What problem does this PR solve?
Problem Summary:
Generated columns are substituted into dependent expressions before
conversion to their declared types. For `c BOOLEAN AS (a)` and `d INT AS (c +
1)`, inserting `a = 2` stores `c = true` but `d = 3`, while evaluating `c + 1`
from the stored column returns `2`. Similarly, `x = 1.7`, `c INT AS (x)`, and
`d DOUBLE AS (c + 0.25)` incorrectly store `d = 1.95` instead of `1.25`.
Cast each generated expression to its declared column type before
registering it for substitution into dependent generated columns in `BindSink`.
This also applies to new writes into existing tables; previously stored
incorrect values are not recalculated.
### Release note
Fix incorrect generated column values when a generated column references
another generated column whose expression type differs from its declared type.
### Check List (For Author)
- Test
- [x] Regression test
- Passed `test_generated_column_declared_type`,
`test_generated_column`, and `test_generated_column_update`.
- Added coverage for boolean and numeric dependency chains, NULLs,
INSERT VALUES, INSERT SELECT, INSERT OVERWRITE, and numeric Stream Load.
Expected output was generated with `run-regression-test.sh` and verified in a
subsequent run.
- [ ] Unit Test
- [x] Manual test (add detailed scripts or steps below)
- Reproduced both examples above before replacing FE libraries and
verified correct new writes into the same tables after replacement.
- FE build and Checkstyle passed using `DISABLE_BUILD_UI=ON
./build.sh --fe`; the test FE used `be_exec_version=13` to match the existing
BE.
- An additional boolean-chain Stream Load check hit a BE column-type
mismatch with both the original and patched FE; that pre-existing failure is
not addressed here.
- [ ] No need to test or manual test. Explain why:
- Behavior changed:
- [ ] No.
- [x] Yes. Dependent generated columns use values converted to the
referenced columns' declared types.
- Does this need documentation?
- [x] No.
- [ ] Yes.
### 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]