A fix for #17401 has the caveat of producing less ideal query plans.
The plan now has an extra sort where the plan before hand had no sort after the BoundedWindowAggExec
Per #14813 (comment), we should be able to get such better query plan with only linear cost in the planner (not exponential).
Originally posted by @alamb in #17563 (comment)