Skip to content

Window aggregate FILTER evaluates arguments for rejected rows #24507

Description

@lyne7-sc

Describe the bug

Window aggregates evaluate their argument expressions before applying the aggregate FILTER.

This can cause a query to fail while evaluating rows that should not participate in the window aggregate.

To Reproduce

SELECT
  id,
  SUM(10 / x) FILTER (WHERE x <> 0) OVER (ORDER BY id) AS running_sum
FROM (
  VALUES
    (1, 2),
    (2, 0),
    (3, 5)
) AS t(id, x)
ORDER BY id;

The query fails even though the row where x = 0 is rejected by the aggregate filter:

Arrow error: Divide by zero error

Expected behavior

The aggregate filter should prevent argument evaluation for rejected rows, and the query should return:

1 5
2 5
3 7

Additional context

This is the window-aggregate counterpart of #24443.

#24444 addresses the same evaluation-order issue for grouped aggregates, but window aggregates use a separate physical evaluation path and remain affected.

Activity

  1. added theissue type on Aug 20, 2026
  2. lyne7-sc commented on Aug 20, 2026

    @lyne7-sc
    ContributorAuthor

    take

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions