Skip to content

internal error with ordering in a window #16649

@DylanZA

Description

@DylanZA

What happens?

I get an internal error in the below code.
it goes away if you remove the ORDER BY idx inside LAST()

More generally (I think we'll raise a discussion later) its not entirely clear from the docs when you need to order inside a general purpose aggregation function if you have an ordering in the partition

To Reproduce

import duckdb
print(duckdb.__version__)
duckdb.sql("""
with IDS as (
    select * as idx from generate_series(1,4)
),DATA as (
    select *, (case when idx != 3 then idx * 1.0 else NULL end) as value from IDS
)
SELECT 
 last(value ORDER BY idx IGNORE NULLS) OVER (ORDER BY idx ROWS BETWEEN UNBOUNDED PRECEDING AND 0 FOLLOWING)
FROM DATA
""")

OS:

linux

DuckDB Version:

1.2.1

DuckDB Client:

python

Hardware:

No response

Full Name:

Dylan Yudaken

Affiliation:

Qubos

What is the latest build you tested with? If possible, we recommend testing with the latest nightly build.

I have tested with a stable release

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

Yes

Did you include all code required to reproduce the issue?

  • Yes, I have

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

  • Yes, I have

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions