aalexandrov commented on code in PR #11456: URL: https://github.com/apache/datafusion/pull/11456#discussion_r1677146980
########## datafusion/sql/src/planner.rs: ########## @@ -151,6 +155,29 @@ impl PlannerContext { schema } + // return a clone of the outer FROM schema + pub fn outer_from_schema(&self) -> Option<Arc<DFSchema>> { + self.outer_from_schema.clone() + } + + /// sets the outer FROM schema, returning the existing one, if any + pub fn set_outer_from_schema( + &mut self, + mut schema: Option<DFSchemaRef>, + ) -> Option<DFSchemaRef> { + std::mem::swap(&mut self.outer_from_schema, &mut schema); + schema + } + + /// extends the FROM schema, returning the existing one, if any + pub fn extend_outer_from_schema(&mut self, schema: &DFSchemaRef) -> Result<()> { + self.outer_from_schema = match self.outer_from_schema.as_ref() { + Some(from_schema) => Some(Arc::new(from_schema.join(schema)?)), Review Comment: ~See [my other comment](https://github.com/apache/datafusion/pull/11456/files#r1677146927).~ Actually, looking at the Postgres behavior it seems that keeping `join` here is better (the `j1_id` column reference is then reported as ambiguous): ```sql SELECT j1_string, j2_string FROM j1 AS x JOIN j1 as y USING(j1_string) LEFT JOIN LATERAL (SELECT * FROM j2 WHERE j1_id < j2_id) AS j2 ON(true); ``` -- 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