You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Decorrelate a window function below a correlated equality filter by extending PARTITION BY #25897
PullUpCorrelatedExpr now pulls a correlated filter above a Window only when the filter reads plain PARTITION BY columns. Any other correlated filter below a window keeps the subquery correlated, and the query fails with "Physical plan does not support logical expression …". For example (#25792):
SELECTt1.id, sub.id, sub.rnFROM t1, LATERAL (
SELECTt2.id, row_number() OVER (ORDER BYt2.id) AS rn
FROM (SELECT*FROM t2 WHEREt2.t1_id=t1.id) AS t2
) AS sub;
Proposal: when every correlated conjunct below the window has the form inner_col = <outer expr>, it fixes inner_col for each outer row. We can then add inner_col to the PARTITION BY of every window function and pull the filter above the window. Spark (DecorrelateInnerQuery, Window case) and DuckDB (FlattenDependentJoins::PushDownWindow) do this. A Projection on top restores the original window column names.
Caveats:
Only a plain column equality qualifies. can_pullup_over_aggregation also accepts CAST(col AS …) = outer, and a lossy cast would map several col values to one outer row, so partitioning by col would give wrong results.
Skip it when the window's input needs the count-bug handling.
Activity
feat: decorrelate a window below a correlated equality filter
feat: decorrelate a window below a correlated equality filter
feat: decorrelate a window below a correlated equality filter (apache…