Backend API support for pagination
Description
This PR adds offset-based pagination support for PPL queries executed through the Calcite engine. Users can now paginate through large result sets by specifying pageSize and offset parameters in the request body
- Simple API: Pass pageSize and offset in the JSON request body
- Respects user intent: User-specified commands like head X from Y are honored first
API Design
Request Format
POST /_plugins/_ppl
{
"query": "source=logs | where status='error' | sort timestamp",
"pageSize": 100,
"offset": 0
}
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| pageSize | int | 0 | Number of rows per page. 0 = pagination disabled |
| offset | int | 0 | Number of rows to skip (0-based) |
Example: Paginating Through Results
Page 1 (rows 0-99):
{ "query": "source=accounts | fields name, age | sort age", "pageSize": 100, "offset": 0 }
Page 2 (rows 100-199):
{ "query": "source=accounts | fields name, age | sort age", "pageSize": 100, "offset": 100 }
Page 3 (rows 200-299):
{ "query": "source=accounts | fields name, age | sort age", "pageSize": 100, "offset": 200 }
Check List
- [ ] New functionality includes testing.
- [ ] New functionality has been documented.
- [ ] New functionality has javadoc added.
- [ ] New functionality has a user manual doc added.
- [ ] New PPL command checklist all confirmed.
- [ ] API changes companion pull request created.
- [ ] Commits are signed per the DCO using
--signoffor-s. - [ ] Public documentation issue/PR created.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. For more information on following Developer Certificate of Origin and signing off your commits, please check here.
[!IMPORTANT]
Review skipped
Draft detected.
Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.
✨ Finishing touches
🧪 Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
Comment @coderabbitai help to get the list of available commands and usage tips.
Can you add some tests in
CalciteExplainIT?Is this query
POST /_plugins/_ppl { "query": "source=logs | where status='error' | sort timestamp", "pageSize": 100, "offset": 1000 }equals to
POST /_plugins/_ppl { "query": "source=logs | where status='error' | sort timestamp | head 100 from 1000" }?
Added test cases in CalciteExplainIT
Is this PR ready for review now?
Not yet, it's currently a POC PR, still need to finalize design