Skip to content

Commit

Permalink
[persist] Fix and test limit-offset query handling (#22592)
Browse files Browse the repository at this point in the history
It looks like the test didn't cover this properly... updated, sorry about that!
  • Loading branch information
bkirwi authored Oct 23, 2023
1 parent aff5730 commit b185c3c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/adapter/src/coord/peek.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,8 @@ impl crate::coord::Coordinator {
let metrics = self.metrics.clone();
let handle: JoinHandle<Result<PeekResponseUnary, String>> =
mz_ore::task::spawn(|| "persist::peek", async move {
let mut limit_remaining = finishing.limit.unwrap_or(usize::MAX);
let mut limit_remaining =
finishing.limit.unwrap_or(usize::MAX) + finishing.offset;

// Re-used state for processing and building rows.
let mut accum = vec![];
Expand Down
22 changes: 21 additions & 1 deletion test/sqllogictest/persist-fast-path.slt
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ SELECT value from numbers LIMIT 20;
10

query T
SELECT value from numbers LIMIT 20 OFFSET 6;
SELECT value from numbers LIMIT 10 OFFSET 6;
----
4
5
Expand Down Expand Up @@ -164,3 +164,23 @@ Used Indexes:
- materialize.public.numbers_primary_idx (fast path limit)

EOF

# Issue 22577
statement ok
CREATE TABLE t1 (f1 INTEGER);

statement ok
INSERT INTO t1 VALUES (2), (2);

statement ok
INSERT INTO t1 VALUES (1);

query T
SELECT * FROM t1 LIMIT 1 OFFSET 0;
----
1

query T
SELECT * FROM t1 LIMIT 1 OFFSET 1;
----
2

0 comments on commit b185c3c

Please sign in to comment.