Skip to content

branch-4.0: [feature](fe) Support ORDER BY and LIMIT clauses for UPDATE and DELETE commands #61681#61751

Merged
yiguolei merged 1 commit intobranch-4.0from
auto-pick-61681-branch-4.0
Mar 26, 2026
Merged

branch-4.0: [feature](fe) Support ORDER BY and LIMIT clauses for UPDATE and DELETE commands #61681#61751
yiguolei merged 1 commit intobranch-4.0from
auto-pick-61681-branch-4.0

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

Cherry-picked from #61681

…E commands (#61681)

### What problem does this PR solve?

Problem Summary: MySQL supports ORDER BY and LIMIT clauses in single-table
UPDATE and DELETE statements, but Doris does not. This PR adds support
for these clauses so users can write statements like:

```sql
DELETE FROM table1 ORDER BY c1 ASC NULLS FIRST LIMIT 10, 3;
UPDATE table1 SET c1 = 10 ORDER BY c2 LIMIT 100, 20;
```

The implementation reuses the existing `queryOrganization` grammar rule and
`withQueryOrganization` builder method. For DELETE, when ORDER BY or
LIMIT is present, the statement is routed through `DeleteFromUsingCommand`
(INSERT INTO SELECT path) which naturally supports sort/limit semantics.
For UPDATE, the queryOrganization is applied to the query plan after `withFilter`.

### Release note

Support ORDER BY and LIMIT clauses in UPDATE and DELETE statements, consistent with MySQL single-table UPDATE/DELETE syntax.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions bot requested a review from yiguolei as a code owner March 26, 2026 06:16
@Thearas
Copy link
Copy Markdown
Contributor

Thearas commented Mar 26, 2026

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@dataroaring dataroaring reopened this Mar 26, 2026
@Thearas
Copy link
Copy Markdown
Contributor

Thearas commented Mar 26, 2026

run buildall

@yiguolei yiguolei merged commit 02d0298 into branch-4.0 Mar 26, 2026
26 of 29 checks passed
@github-actions github-actions bot deleted the auto-pick-61681-branch-4.0 branch March 26, 2026 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants