Skip to content

Aggregate FILTER fails on NULL predicate #22773

Closed

Description

@pchintar

Describe the bug

Aggregate and window aggregate FILTER clauses currently fail with an internal error for FILTER (WHERE NULL).

To Reproduce

Aggregate:

SELECT count(*) FILTER (WHERE NULL);

Output:

Internal error: Cannot create filter_array from non-boolean predicates.

Window aggregate:

SELECT count(*) FILTER (WHERE NULL) OVER ()
FROM (VALUES (1)) AS t(x);

Output:

Internal error: could not cast array of type Null to BooleanArray.

Expected behavior

The equivalent queries with a boolean-typed NULL predicate already work:

SELECT count(*) FILTER (WHERE CAST(NULL AS BOOLEAN));
0
SELECT sum(1) FILTER (WHERE CAST(NULL AS BOOLEAN));
NULL

Untyped NULL predicates in FILTER clauses should behave consistently rather than producing an internal error.

Environment

  • DataFusion 53.1.0
  • Reproduced in datafusion-cli

Activity

  1. added theissue type on Jun 5, 2026
  2. mkleen commented on Jun 5, 2026

    @mkleen
    Contributor

    take

  3. pchintar commented on Jun 5, 2026

    @pchintar
    ContributorAuthor

    take

    hi @mkleen thnx for showing interest on my issue, so I already worked on the fix for this issue and opened the PR for it just now.

  4. added a commit that references this issue on Jun 8, 2026
    e4ae236
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