jonahgao commented on code in PR #11456: URL: https://github.com/apache/datafusion/pull/11456#discussion_r1679583531
########## datafusion/sql/src/relation/mod.rs: ########## @@ -143,4 +147,49 @@ 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(); Review Comment: I tested the following query, and it panicked. It's valid in PostgreSQL. ```sh DataFusion CLI v40.0.0 > select * from lateral (select 1) t; thread 'main' panicked at datafusion/datafusion/sql/src/relation/mod.rs:162:75: called `Option::unwrap()` on a `None` value ``` -- 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