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

   ### What problem does this PR solve?
   
   Issue Number: #65871
   
   Related PR: #66713 (master), #66757 (global ordering on 4.1), #68949 (cloud 
visible versions on 4.1)
   
   Problem Summary:
   
   Backport #66713 to `branch-4.1`. On the 4.1 baseline, `SHOW TABLETS FROM t 
LIMIT 0` returns every matching row. Large `LIMIT` and `OFFSET` values can 
overflow when added, and a query with only `LIMIT` sorts the subset collected 
by the scan.
   
   ### Details
   
   The parser now distinguishes an omitted `LIMIT` from an explicit zero. The 
command clamps the bounds before adding them. An explicit `ORDER BY` sorts all 
matching rows before pagination. A query with only `LIMIT` returns rows in scan 
order, and an unbounded query without `ORDER BY` retains its `TabletId, 
ReplicaId` order.
   
   The backport retains 4.1's batched partition visible-version lookup and uses 
each partition's version when reading its tablets. `LIMIT 0` completes table 
and partition validation before returning an empty result, so it needs neither 
version lookup nor tablet enumeration. Sorting and formatting use rows copied 
under the table read lock.
   
   The existing command unit tests covered validation. The existing regression 
exercised positive bounds and asserted that a bounded scan returned sorted IDs. 
The updated suite checks both directions of an explicit partition list, zero 
limits and very large offsets.
   
   ### Release note
   
   `SHOW TABLETS ... LIMIT 0` returns an empty result. Large offsets and limits 
no longer overflow. Without an explicit `ORDER BY`, a limited query returns 
rows in scan order.
   
   ### Testing
   
   - `./run-fe-ut.sh --run 
org.apache.doris.nereids.trees.plans.commands.ShowTabletsFromTableCommandTest,org.apache.doris.common.proc.CloudProcVersionDisplayTest`
 passed all 12 tests.
   - FE and ASAN BE built on macOS arm64. FE Checkstyle reported zero 
violations.
   - `./run-regression-test.sh --run -d show_p0 -s test_show_tablet` passed on 
a local FE and BE. The suite exercised global ordering, scan order, zero limits 
and large offsets.
   
   ### Check List (For Author)
   
   - Test
       - [x] Regression test
       - [x] Unit Test
       - [ ] Manual test
   - Behavior changed:
       - [ ] No.
       - [x] Yes. See the release note.
   - Does this need documentation?
       - [x] No.
       - [ ] Yes.
   - Pre-submission status: Ready
   
   ### 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