neilconway commented on code in PR #21240:
URL: https://github.com/apache/datafusion/pull/21240#discussion_r3080266272
##########
datafusion/core/src/physical_planner.rs:
##########
@@ -379,8 +385,95 @@ impl DefaultPhysicalPlanner {
Ok(())
}
- /// Create a physical plan from a logical plan
- async fn create_initial_plan(
+ /// Collect uncorrelated scalar subqueries. We don't descend into nested
+ /// subqueries here: each call to `create_initial_plan` handles subqueries
+ /// at its level and then recurses in order to handle nested subqueries.
+ fn collect_scalar_subqueries(plan: &LogicalPlan) -> Vec<Subquery> {
+ let mut subqueries = Vec::new();
+ let mut seen = HashSet::new();
+ plan.apply(|node| {
+ for expr in node.expressions() {
+ expr.apply(|e| {
+ if let Expr::ScalarSubquery(sq) = e
+ && sq.outer_ref_columns.is_empty()
+ && seen.insert(sq.clone())
+ {
+ subqueries.push(sq.clone());
Review Comment:
I made some improvements to reduce unnecessary cloning; I also switched to
`IndexSet`, which is simpler than `HashSet` + `Vec`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]