Add Expr::Exists to represent EXISTS subquery expression#2339
Add Expr::Exists to represent EXISTS subquery expression#2339andygrove merged 7 commits intoapache:masterfrom
Expr::Exists to represent EXISTS subquery expression#2339Conversation
alamb
left a comment
There was a problem hiding this comment.
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))? |
| // input: Arc::new(inputs[0].clone()), | ||
| // schema, | ||
| // })) | ||
| Err(DataFusionError::Plan("not implemented".to_string())) |
There was a problem hiding this comment.
| 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.
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.
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.
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.