-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Add Expr::Exists to represent EXISTS subquery expression
#2339
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
alamb
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.
Looks good to me.
Very excited to see the PR 🚋 for subqueries leave the station, so to speak 👍
|
|
||
| let outer_query = LogicalPlanBuilder::from(bar) | ||
| .project(vec![col("a")])? | ||
| .filter(exists(subquery))? |
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.
👌
| // input: Arc::new(inputs[0].clone()), | ||
| // schema, | ||
| // })) | ||
| Err(DataFusionError::Plan("not implemented".to_string())) |
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.
| Err(DataFusionError::Plan("not implemented".to_string())) | |
| Err(DataFusionError::Plan("subquery support is not full implemented yet".to_string())) |
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 have now implemented this section of code, although it is not exercised by any tests yet
datafusion/expr/src/expr_fn.rs
Outdated
| } | ||
|
|
||
| /// Create an EXISTS subquery expression | ||
| pub fn exists(subquery: LogicalPlan) -> Expr { |
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 wonder if this function should also be added to the prelude: https://github.com/apache/arrow-datafusion/blob/b890190a6521ab1e572184dcf6ea0a5afb3a47af/datafusion/core/src/prelude.rs#L33-L40
datafusion/expr/src/expr_fn.rs
Outdated
| } | ||
|
|
||
| /// Create an EXISTS subquery expression | ||
| pub fn exists(subquery: LogicalPlan) -> Expr { |
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.
Maybe this function could take an Arc<LogicalPlan> so if someone already has one they can reuse it rather than making a copy to pass in here
Co-authored-by: Andrew Lamb <[email protected]>
Which issue does this PR close?
Closes #2337 and is part of #2248
Rationale for this change
This is the first step towards supporting
EXISTSsubquery expressions. This work is partly based on work by @paveltiunov in cube-js@d14f0deWhat changes are included in this PR?
Expr::Exists(Subquery)expressionLogicalPlan::Subquery, although that wasn't strictly necessary just to supportEXISTSEXISTSusingLogicalPlanBuilderAre there any user-facing changes?
API change.