-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Is your feature request related to a problem or challenge?
Window functions are cardinality preserving, they just might need to see more data than the limits applied after them, so we should be able to push limits down through them, assuming we know how to grow the limits appropriately.
Describe the solution you'd like
This is fairly trivial if WindowFrameUnits::Rows
, so let's start there. Assume we have a plan like:
GlobalLimitExec fetch=5
--BoundedWindowAggExec:[sum(c4) ORDER BY [c4 ASC] ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING
----SortExec: expr=[c4@0 ASC NULLS LAST], preserve_partitioning=[false]
We should be able to transform it into:
GlobalLimitExec fetch=5
--BoundedWindowAggExec:[sum(c4) ORDER BY [c4 ASC] ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING
----SortExec: TopK(fetch=7), expr=[c4@0 ASC NULLS LAST], preserve_partitioning=[false]
Describe alternatives you've considered
Ignore opportunities like this.
Additional context
No response
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request