Ted-Jiang commented on PR #2638:
URL:
https://github.com/apache/arrow-datafusion/pull/2638#issuecomment-1140861506
> > > builder.limit(100).offset(10) means ignore the first 10 rows and then
starting to count 100 rows. Now it
> > > means returns 100 rows and then skip 10 rows.
> > > @ming535 If this happened, means only return 90 rows?
>
> Yes. The current design of plan builder tries to mimics the semantics of
SQL language; this PR tries to mimics the tree structure of logical operator.
>
> We can add another api for the builder to combines `limit` and `offset` to
mimics SQL language. For example: `fetch(offset: Option<usize>, limit:
Option<usize>)`
Before i impl the rule i test in pg
```
postgres=# select * from users offset 1 limit 12 ;
id | hash_firstname | hash_lastname |
gender
----+----------------------------------+----------------------------------+--------
2 | f5e8f62332c256ebdceea3050a1da595 | 5d6c111b409bd97b5b8e5357668564d7 |
male
3 | ff82b6f31f4b4a7647ded507a599147a | cb9a959c8e42ee8f1de33c50c15b2267 |
male
4 | a643dd92e5a999e9372d73373cceb407 | 68ae1a597b5b04daa3f029573dde4fb9 |
female
5 | f7f6c7f939202806ebe4cdda0821b1f8 | 7a451c9e30238af75001423f17f300ac |
male
6 | 37f9869968840feaf441f963e2171254 | 6a06f56a6e66ee457ddc547b7df20de4 |
female
7 | e2c4c7cb13dd5f2511d3402d36cb4884 | 7cc3e36824f369b88a3445b5dc2b36d4 |
female
8 | aea96778de92539cc9b80864a969c82b | 92517c35f9f1baf0ed831eab4c23757e |
male
9 | 363547e325516d28f96b69a8e88deb44 | 4e6cadf5f26aacca0f8c03c115825fbe |
female
10 | 340d4e6b3968e80c2fb02704a30fc574 | e0b7b41ae5397ae231c783e4e5d9d848 |
female
11 | 3c8e1102dc3c9551be2fb40e4dbc0bc7 | d20d0155652a23c327734fb0e0127247 |
female
12 | cc70f3378a9364603023924670b8bb0d | ac16e18018a438445e12492bf018cf0f |
male
13 | 78cecc8caaf5c303097eb3816a411e79 | a0a19a4b5b595562fc8b978520401166 |
female
(12 rows)
postgres=# select * from users limit 10 offset 1;
id | hash_firstname | hash_lastname |
gender
----+----------------------------------+----------------------------------+--------
2 | f5e8f62332c256ebdceea3050a1da595 | 5d6c111b409bd97b5b8e5357668564d7 |
male
3 | ff82b6f31f4b4a7647ded507a599147a | cb9a959c8e42ee8f1de33c50c15b2267 |
male
4 | a643dd92e5a999e9372d73373cceb407 | 68ae1a597b5b04daa3f029573dde4fb9 |
female
5 | f7f6c7f939202806ebe4cdda0821b1f8 | 7a451c9e30238af75001423f17f300ac |
male
6 | 37f9869968840feaf441f963e2171254 | 6a06f56a6e66ee457ddc547b7df20de4 |
female
7 | e2c4c7cb13dd5f2511d3402d36cb4884 | 7cc3e36824f369b88a3445b5dc2b36d4 |
female
8 | aea96778de92539cc9b80864a969c82b | 92517c35f9f1baf0ed831eab4c23757e |
male
9 | 363547e325516d28f96b69a8e88deb44 | 4e6cadf5f26aacca0f8c03c115825fbe |
female
10 | 340d4e6b3968e80c2fb02704a30fc574 | e0b7b41ae5397ae231c783e4e5d9d848 |
female
11 | 3c8e1102dc3c9551be2fb40e4dbc0bc7 | d20d0155652a23c327734fb0e0127247 |
female
(10 rows)
postgres=# select * from users offset 1 limit 10 ;
id | hash_firstname | hash_lastname |
gender
----+----------------------------------+----------------------------------+--------
2 | f5e8f62332c256ebdceea3050a1da595 | 5d6c111b409bd97b5b8e5357668564d7 |
male
3 | ff82b6f31f4b4a7647ded507a599147a | cb9a959c8e42ee8f1de33c50c15b2267 |
male
4 | a643dd92e5a999e9372d73373cceb407 | 68ae1a597b5b04daa3f029573dde4fb9 |
female
5 | f7f6c7f939202806ebe4cdda0821b1f8 | 7a451c9e30238af75001423f17f300ac |
male
6 | 37f9869968840feaf441f963e2171254 | 6a06f56a6e66ee457ddc547b7df20de4 |
female
7 | e2c4c7cb13dd5f2511d3402d36cb4884 | 7cc3e36824f369b88a3445b5dc2b36d4 |
female
8 | aea96778de92539cc9b80864a969c82b | 92517c35f9f1baf0ed831eab4c23757e |
male
9 | 363547e325516d28f96b69a8e88deb44 | 4e6cadf5f26aacca0f8c03c115825fbe |
female
10 | 340d4e6b3968e80c2fb02704a30fc574 | e0b7b41ae5397ae231c783e4e5d9d848 |
female
11 | 3c8e1102dc3c9551be2fb40e4dbc0bc7 | d20d0155652a23c327734fb0e0127247 |
female
(10 rows)
```
Use offset before limit should also return 10 rows.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]