Skip to content

Grouped aggregate FILTER evaluates arguments for rejected rows #24443

Closed

Description

@lyne7-sc

Describe the bug

Grouped 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 aggregate.

To Reproduce

SELECT
  g,
  SUM(10 / v) FILTER (WHERE v <> 0)
FROM (
  VALUES
    (1, 0),
    (2, 2),
    (3, 0),
    (4, 5)
) AS t(g, v)
GROUP BY g
ORDER BY g;

The query fails even though rows where v = 0 are 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 NULL
2 5
3 NULL
4 2

Groups whose rows are all rejected by the aggregate filter should still be present, with a NULL aggregate result.

Additional context

No response

Activity

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

    @lyne7-sc
    ContributorAuthor

    take

  3. added a commit that references this issue on Aug 21, 2026
    5610e58
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