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 morrySnow as a code owner November 22, 2025 08:26
@hello-stephen
Copy link
Contributor

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?

@hello-stephen
Copy link
Contributor

run buildall

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.

2 participants