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

   ### What problem does this PR solve?
   
   Problem Summary:
   
   CREATE TABLE LIKE reconstructs generated columns from SQL using the caller's 
session settings, losing the expression settings saved in the source columns. 
For a generated expression `a * b` over `DECIMAL(20,5)` and `DECIMAL(21,6)`, a 
source created with `enable_decimal256=true` produces `1.26212529751`, but a 
clone created with the option disabled produces `1.26212530000` for the same 
input. SQL mode also affects parsing: a source expression `a || 'x'` created 
with `PIPES_AS_CONCAT` produces `ax`, while its clone can produce NULL under a 
different SQL mode.
   
   Snapshot each generated column's session settings under the source table's 
read lock and carry them through `GeneratedColumnDesc`. Restore these settings 
temporarily when parsing and analyzing the cloned expression, then persist them 
in the new `Column`. The caller's session is restored after analysis, including 
on exceptions. Ordinary CREATE TABLE retains its existing session behavior.
   
   Existing incorrectly created clones and stored data are not automatically 
repaired.
   
   ### Release note
   
   Fix CREATE TABLE LIKE changing generated column results when the caller's 
expression-related session settings differ from the source table's settings.
   
   ### Check List (For Author)
   
   - Test
       - [x] Regression test
           - Passed `test_generated_column_like_session`, 
`test_generated_column`, and `test_generated_column_fault_tolerance_nereids` on 
the final branch's FE.
           - New coverage includes both decimal256 setting directions, repeated 
LIKE, SQL mode, NULL values, and preservation of the caller's session. Expected 
output was generated by `run-regression-test.sh` and verified in subsequent 
runs.
       - [x] Unit Test
           - All 11 `CreateTableLikeTest` tests passed via `run-fe-ut.sh` on 
the initial validation baseline with the same repair and test files.
           - The final upstream baseline has an unrelated test-compilation 
error in `IvmNormalizeMTMVJoinTest` (an outdated `IvmRewriteContext` 
constructor call). Final FE packaging therefore used `DISABLE_BUILD_UI=ON 
MVN_OPT=-Dmaven.test.skip=true ./build.sh --fe`. No unrelated test code was 
changed. Checkstyle passed.
       - [x] Manual test (add detailed scripts or steps below)
           - Reproduced both precision and SQL mode differences before 
replacing FE libraries; verified correct results after replacement.
           - Restarted the final FE and cloned previously created fixed tables 
again, verifying persisted session settings and unchanged caller settings.
           - The test FE used `be_exec_version=13` to match its existing BE.
       - [ ] No need to test or manual test. Explain why:
   
   - Behavior changed:
       - [ ] No.
       - [x] Yes. Generated columns created through LIKE preserve the source 
columns' expression semantics.
   
   - 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]

Reply via email to