-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add Expr::Exists
to represent EXISTS subquery expression
#2339
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
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
@@ -180,6 +182,13 @@ pub fn approx_percentile_cont_with_weight( | |||
} | |||
} | |||
|
|||
/// 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
@@ -180,6 +182,13 @@ pub fn approx_percentile_cont_with_weight( | |||
} | |||
} | |||
|
|||
/// 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 <andrew@nerdnetworks.org>
Which issue does this PR close?
Closes #2337 and is part of #2248
Rationale for this change
This is the first step towards supporting
EXISTS
subquery 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 supportEXISTS
EXISTS
usingLogicalPlanBuilder
Are there any user-facing changes?
API change.