-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat: support Set Comparison Subquery #19109
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
kosiew
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.
Thanks for your contribution.
| async fn set_comparison_all_empty() -> Result<()> { | ||
| let ctx = SessionContext::new(); |
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.
how about adding
async fn set_comparison_type_mismatch() -> Result<()> {
// SELECT v FROM t WHERE v > ANY (SELECT s FROM strings)
// INT > STRING should error with clear message
...
too?
| )?; | ||
|
|
||
| let df = ctx | ||
| .sql("select v from t where v < all(select v from e)") |
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 think tests for:
- Multiple operators (
=,!=,>=,<=) - NULL semantics (e.g.,
5 != ALL (1, NULL)
would improve test coverage
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.
Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
Which issue does this PR close?
Rationale for this change
Support Set Comparison Subquery (or Quantified Comparison Subquery in some systems), it looks like
or
What changes are included in this PR?
ExprbranchExpr::SetComparisonand correspondingSetComparisonstructRewriteSetComparisonto translate this kind of subquery using existing componentsRewriteSetComparisonis a very naive implementation. We can optimize it in various ways in the follow-up PRs, like using min/max for non-equal comparison operators etc.Are these changes tested?
Yes, by unit test and slt
Are there any user-facing changes?
To SQL user, this is a new feature. To API user,
ExprPlanner::plan_anyis removed (not needed)