nuno-faria commented on code in PR #25547:
URL: https://github.com/apache/datafusion/pull/25547#discussion_r4057220650
##########
datafusion/sql/src/unparser/plan.rs:
##########
@@ -1632,7 +1632,11 @@ impl Unparser<'_> {
// we must emit a derived subquery: (SELECT ...) AS alias.
// Without this, the recursive handler would merge those
clauses
// into the outer SELECT, losing the subquery structure
entirely.
- if unparsed_table_scan.is_none() &&
Self::requires_derived_subquery(plan)
+ // Also, do not add a table alias past a Filter, as otherwise
the predicates might
+ // refer to invalid tables.
+ if (unparsed_table_scan.is_none()
+ && Self::requires_derived_subquery(plan))
+ || matches!(plan, LogicalPlan::Filter(_))
Review Comment:
I did not add the `Filter` directly to `requires_derived_subquery` since
technically the filter does not need it, but we can't also alias the table.
--
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]