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

   ### What problem does this PR solve?
   
   Issue Number: None
   
   Related PR: None
   
   Problem Summary:
   
   When a CTE was materialized, `AddDefaultLimit` rebuilt the 
`LogicalCTEAnchor` without visiting its result child. As a result, the query 
result could bypass `sql_select_limit`, for example when two `UNION ALL` 
branches referenced the same CTE.
   
   This change visits the CTE result branch while preserving the producer. It 
also adds a unit test for the rewritten plan shape and a regression test 
covering the materialized CTE query result.
   
   ### Release note
   
   Fix `sql_select_limit` not taking effect for queries using materialized CTEs.
   
   ### Check List (For Author)
   
   - Test
       - [x] Regression test
       - [x] Unit Test
       - [ ] Manual test (add detailed scripts or steps below)
       - [ ] No need to test or manual test. Explain why:
           - [ ] This is a refactor/code format and no logic has been changed.
           - [ ] Previous test can cover this change.
           - [ ] No code files have been changed.
           - [ ] Other reason
   
     Commands run:
     - `./run-fe-ut.sh --run 
org.apache.doris.nereids.rules.rewrite.AddDefaultLimitTest`
     - `./run-regression-test.sh --run -d query_p0/session_variable -s 
test_default_limit`
   
   - Behavior changed:
       - [ ] No.
       - [x] Yes. Materialized CTE query results now obey `sql_select_limit`.
   
   - 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