pub(super) fn rewrite_qualify(plan: LogicalPlan) -> Result<LogicalPlan>Expand description
Rewrite Filter plans that have a Window as their input by inserting a SubqueryAlias.
When a Filter directly operates on a Window plan, it can cause issues during SQL unparsing because window functions in a WHERE clause are not valid SQL. The solution is to wrap the Window plan in a SubqueryAlias, effectively creating a derived table.
Example transformation:
Filter: condition Window: window_function TableScan: table
becomes:
Filter: condition SubqueryAlias: __qualify_subquery Projection: table.column1, table.column2 Window: window_function TableScan: table