JoeryH commented on code in PR #26317:
URL: https://github.com/apache/datafusion/pull/26317#discussion_r4645591148
##########
datafusion/sql/src/select.rs:
##########
@@ -1114,9 +1129,16 @@ impl<S: ContextProvider> SqlToRel<'_, S> {
) -> Result<Vec<SelectExpr>> {
let mut prepared_select_exprs = Vec::with_capacity(projection.len());
let mut error_builder = DataFusionErrorBuilder::new();
+ let mut using_columns = LazyUsingColumns::default();
Review Comment:
Thanks @alamb! I don't think it fits on PlannerContext: the set depends on
the SELECT's input plan, and the context is shared by every SELECT in the query
(derived tables, subqueries, set-operation legs, CTEs), each with a different
input. Keeping it correct there would mean saving and restoring it around every
SELECT like outer_queries_schemas_stack, or keying it by plan. One projection
is exactly the scope where the input is fixed, so that's where the cache lives.
What's left is that each nested SELECT still walks its own input once, inner
SELECTs included. Reusing an inner SELECT's set in the outer one could remove
that, but it needs a way to tie sets to subtrees. Happy to file a follow-up if
profiles show it's still significant after this.
--
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]