Skip to content

Sliding window min() returns stale value when all non-NULL values leave the frame #23872

Closed

Description

@neilconway

Describe the bug

SlidingMinAccumulator reports a stale minimum when every non-NULL value has been retracted from the window but the frame is still non-empty (i.e., the frame contains only NULLs). Sliding max is correct.

To Reproduce

SELECT id, x,
       MIN(x) OVER (ORDER BY id ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS min_x
FROM (VALUES (1, 3), (2, NULL), (3, NULL)) t(id, x)
ORDER BY id;

==>

+----+------+-------+
| id | x    | min_x |
+----+------+-------+
| 1  | 3    | 3     |
| 2  | NULL | 3     |
| 3  | NULL | 3     |
+----+------+-------+

Expected behavior

Postgres and DuckDB both return the expected results:

+----+------+-------+
| id | x    | min_x |
+----+------+-------+
| 1  | 3    | 3     |
| 2  | NULL | 3     |
| 3  | NULL | NULL  |
+----+------+-------+

Additional context

No response

Activity

  1. added theissue type on Jul 24, 2026
  2. neilconway commented on Jul 24, 2026

    @neilconway
    ContributorAuthor

    take

  3. added a commit that references this issue on Jul 27, 2026
    2028927
  4. added a commit that references this issue on Aug 12, 2026
    48b4cf1
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