-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: substrait limit when fetch is None #7669
Conversation
Signed-off-by: Ruihang Xia <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @waynexia
This looks good to me.
I took the liberty of merging up from main to resolve a conflict and adding a comment about the use of USIZE::max
@@ -442,7 +442,7 @@ impl LimitStream { | |||
|
|||
match &poll { | |||
Poll::Ready(Some(Ok(batch))) => { | |||
if batch.num_rows() > 0 && self.skip == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the rationale that this condition is redundant because any batch with zero rows will also have self.skip equal to zero?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. To my understanding these two conditions are identical. So I removed one to make it simpler
* fix: substrait limit when fetch is None Signed-off-by: Ruihang Xia <[email protected]> * Add comments --------- Signed-off-by: Ruihang Xia <[email protected]> Co-authored-by: Andrew Lamb <[email protected]>
Which issue does this PR close?
related to GreptimeTeam/greptimedb#2495
Rationale for this change
I found the producer will replace
fetch = None
withfetch = 0
, and consumer will always putSome
in the position of fetch. This is incorrect for query withoutLIMIT
, e.g.:SELECT * FROM t OFFSET 1
What changes are included in this PR?
Fix the bug. As substrait cannot express
None
, I useusize::MAX
to representNone
in producer, and convert it back toNone
in consumer.This patch also has a minor change in
LimitExec
. I thought that condition was redundant so I removed it.Are these changes tested?
I add a new round trip case
Are there any user-facing changes?
No