aalexandrov commented on code in PR #11456: URL: https://github.com/apache/datafusion/pull/11456#discussion_r1677146927
########## datafusion/sql/src/relation/mod.rs: ########## @@ -143,4 +147,45 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> { Ok(plan) } } + + pub(crate) fn create_relation_subquery( + &self, + subquery: TableFactor, + planner_context: &mut PlannerContext, + ) -> Result<LogicalPlan> { + // At this point for a syntacitally valid query the outer_from_schema is + // guaranteed to be set, so the `.unwrap()` call will never panic. This + // is the case because we only call this method for lateral table + // factors, and those can never be the first factor in a FROM list. This + // means we arrived here through the `for` loop in `plan_from_tables` or + // the `for` loop in `plan_table_with_joins`. + let old_from_schema = planner_context.set_outer_from_schema(None).unwrap(); + let new_query_schema = match planner_context.outer_query_schema() { + Some(lhs) => Some(Arc::new(lhs.join(&old_from_schema)?)), Review Comment: We probably want to replace the `lhs.join(<rhs>)` call here with aversion of a `join` where duplicate columns on the right side override their `lhs` counterpart. See #11464 for details. -- 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: github-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org