-
Notifications
You must be signed in to change notification settings - Fork 710
fix(binder): fix explain with parameters; simplify IN expr without consts #23579
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
Conversation
xiangjinwu
left a comment
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 unfriendly to the const folding and it looks like a bug as well
Could you elaborate on this?
- I agree it is redundant and better removed.
- But is there any correctness issue that we overlooked? If yes how can we reproduce it?
- The two fixes in this PR seems unrelated, one about non-const
INand another about$1inConstEvalRewriter. In which case is the latter code path reachable?
src/frontend/src/binder/expr/mod.rs
Outdated
| FunctionCall::new( | ||
| ExprType::Or, | ||
| vec![ | ||
| ret.unwrap(), |
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.
nit: if-let or let-else to avoid this unwrap()
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.
In which case is the latter code path reachable?
We can simply run explain select $1 to reproduce it.
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.
Adding 2 test cases here.
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.
We can simply run
explain select $1to reproduce it.
I see; so it is indeed unrelated to IN and just blocks the usage of explain when parameter is not provided. select $1 without explain is still rejected (via captured panic) at a later stage: Parameter should not be serialized to ExprNode
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.
I agree it is redundant and better removed.
With the redundant part removed, a single equality condition can be pushed down for index selection. I guess this is the real fix (for performance), right?
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.
True, but we shouldn't panic. And explain is useful to debug this prepared statement.
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.
With the redundant part removed, a single equality condition can be pushed down for index selection. I guess this is the real fix (for performance), right?
Yes. BTW, an in expression without any arguments seems an invalid expression.
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.
Agree. Just trying to understand how each part of the PR contribute to fix for panic and performance.
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.
an in expression without any arguments seems an invalid expression
It is syntactically invalid, but semantically well defined - just testing against an empty set, like IN (subquery) where the subquery returns zero rows. Or did you find any problem in this definition or our existing implementation?
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.
Indeed.It is syntactically invalid, but semantically well defined .
I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.
What's changed and what's your intention?
select * from t where id in ($1)will be converted intoselect * from t where id in() or id = $1which is unfriendly to the const folding and it looks like a bug as well.Checklist
Documentation
Release note