#25698·duckdb

`FIRST_VALUE IGNORE NULLS` raises a vector-capacity internal error

Author: Yibo-DongCreated Sep 14, 2026Updated Sep 17, 2026
Labelsreproduced

What happens?

A legal running FIRST_VALUE(... IGNORE NULLS) raises an internal error when the first non-NULL value occurs at row 2048 instead of returning that value for the remaining rows.

To Reproduce

Code

sql
SET threads=1;
SET enable_optimizer=true;

WITH w AS (
  SELECT
    i,
    FIRST_VALUE(CASE WHEN i = 2048 THEN i END IGNORE NULLS) OVER (
      ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
    ) AS x
  FROM range(2051) AS r(i)
)
SELECT count(*) FILTER (
  WHERE x IS DISTINCT FROM CASE WHEN i >= 2048 THEN 2048 END
) AS bad
FROM w;

Expected

bad
0

Actual

result
INTERNAL Error: Vector::SetSize out of range - trying to set size to 3 for vector with capacity 1

Notes From Minimization

  • SET enable_optimizer=false changes the output to the expected bad = 0.
  • smaller table removes the error

OS:

macOS 15.7.4, arm64

DuckDB Version:

current main (8bc48eb3fe36f13b5e57e5e136c3ba85cc7d74d4, v2.1.0-dev84598)

DuckDB Client:

CLI

Hardware:

No response

Full Name:

Yibo Dong

Affiliation:

National University of Singapore

Did you include all relevant configuration (e.g., CPU architecture, Linux distribution) to reproduce the issue?

  • Yes, I have

Did you include all code required to reproduce the issue?

  • Yes, I have

Did you include all relevant data sets for reproducing the issue?

Yes