Skip to content

Conversation

@github-actions
Copy link
Contributor

Cherry-picked from #58239

…single snapshot scenario (#58239)

### What problem does this PR solve?

Issue Number: close #xxx

Related PR: #xxx

Problem Summary:
When a Paimon table has only 1 snapshot, users cannot perform
incremental queries. The validation logic in Doris has two issues:

1. It rejects queries where `startSnapshotId = endSnapshotId`:
```sql
SELECT * FROM tb_simple@incr('startSnapshotId'='1', 'endSnapshotId'='1');
-- Error: startSnapshotId must be less than endSnapshotId
```

2. It rejects queries where `startSnapshotId = 0` (which is needed to
query all data from a single snapshot):
```sql
SELECT * FROM tb_simple@incr('startSnapshotId'='0', 'endSnapshotId'='1');
-- Error: startSnapshotId must be greater than 0
```

This behavior is inconsistent with Spark Paimon, which:
- Allows `startSnapshotId = endSnapshotId` (returns empty result)
- Allows `startSnapshotId = 0` to query all data from the initial state
to the specified snapshot

## Solution

Align Doris incremental query behavior with Spark Paimon:

1. **Allow `startSnapshotId = 0`**: This enables querying all data from
a single snapshot by using `startSnapshotId=0, endSnapshotId=1`
2. **Allow `startSnapshotId = endSnapshotId`**: This matches Spark
Paimon behavior (returns empty result when querying the same snapshot)
3. **Update validation**: Allow `startSnapshotId >= 0` and
`endSnapshotId >= 0` (previously `> 0`)
@github-actions github-actions bot requested a review from yiguolei as a code owner November 22, 2025 08:27
@Thearas
Copy link
Contributor

Thearas commented Nov 22, 2025

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?

@Thearas
Copy link
Contributor

Thearas commented Nov 22, 2025

run buildall

@morningman morningman closed this Dec 1, 2025
@morningman morningman reopened this Dec 1, 2025
@github-actions github-actions bot added the approved Indicates a PR has been approved by one committer. label Dec 1, 2025
@github-actions
Copy link
Contributor Author

github-actions bot commented Dec 1, 2025

PR approved by at least one committer and no changes requested.

@github-actions
Copy link
Contributor Author

github-actions bot commented Dec 1, 2025

PR approved by anyone and no changes requested.

@yiguolei yiguolei merged commit f62c3bd into branch-4.0 Dec 2, 2025
27 of 29 checks passed
@github-actions github-actions bot deleted the auto-pick-58239-branch-4.0 branch December 2, 2025 02:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by one committer. reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants