mingmwang commented on code in PR #5509:
URL: https://github.com/apache/arrow-datafusion/pull/5509#discussion_r1134838590
##########
datafusion/sql/src/select.rs:
##########
@@ -241,33 +236,26 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
plan: LogicalPlan,
outer_query_schema: Option<&DFSchema>,
planner_context: &mut PlannerContext,
- from_schema: &DFSchema,
) -> Result<LogicalPlan> {
match selection {
Some(predicate_expr) => {
let mut join_schema = (**plan.schema()).clone();
- let mut all_schemas: Vec<DFSchemaRef> = vec![];
- for schema in plan.all_schemas() {
- all_schemas.push(schema.clone());
- }
- if let Some(outer) = outer_query_schema {
- all_schemas.push(Arc::new(outer.clone()));
+
+ let fallback_schemas = plan.fallback_normalize_schemas();
+ let outer_query_schema = if let Some(outer) =
outer_query_schema {
join_schema.merge(outer);
- }
- let x: Vec<&DFSchemaRef> = all_schemas.iter().collect();
+ vec![outer]
+ } else {
+ vec![]
+ };
Review Comment:
The join schema logic is problematic. I will fix it in other PR.
The `filter_expr` might contains reference columns from the
outer_query_schema, at the end, it will create the `Filter` from the
`filter_expr`, and the validation in the `Filter::try_new` will fail
```rust
Ok(LogicalPlan::Filter(Filter::try_new(
filter_expr,
Arc::new(plan),
)?))
```
Actually, in the sub query plan, the out ref columns(correlated columns) can
be in any places which accept expressions(Filter exprs, Projection exprs,
Window exprs, Order by, Aggregate expr, Having, Join exprs, etc).
--
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]