Skip to content

LimitPushPastWindows returns incorrect results for queries with lead() #18028

@avantgardnerio

Description

@avantgardnerio

Describe the bug

Some analytical functions effect the effective window bounds by adding a lookahead (acausal) amount of rows. The current implementation of LimitPushPastWindows does not take this into account, does not grow the limit by the appropriate amount, and does not give them the input data necessary to compute the correct totals.

To Reproduce

Run a query like:

SELECT LEAD(empno) OVER (ORDER BY empno ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM employees LIMIT 3

with datafusion.optimizer.enable_window_limits enabled/disabled to observe different results.

Expected behavior

No response

Additional context

No response

Metadata

Metadata

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions