Skip to content

.aggregate does not raise on bad order statement #339

Closed

Description

@jakkes

What happens?

This seems to compile, but the order by i at the end seems to be doing nothing?

duckdb.query("select unnest([0, 0, 1, 1]) as i, unnest([1, 2, 3, 4]) as x").aggregate("i, first(x) as x order by i")

Given that the 'correct' statement is

duckdb.query("select unnest([0, 0, 1, 1]) as i, unnest([1, 2, 3, 4]) as x").aggregate("i, first(x order by i) as x")

it seems that the former statement should raise an error to avoid mix ups, unless it has a use that I fail to see?

To Reproduce

import duckdb
duckdb.query("select unnest([0, 0, 1, 1]) as i, unnest([1, 2, 3, 4]) as x").aggregate("i, first(x) as x order by i")

OS:

Ubuntu

DuckDB Package Version:

1.4.3

Python Version:

3.10

Full Name:

Jakob Stigenberg

Affiliation:

Qubos Systematic

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?

Not applicable - the reproduction does not require a data set

Did you include all code required to reproduce the issue?

  • Yes, I have

Did you include all relevant configuration to reproduce the issue?

  • Yes, I have

Activity

  1. evertlammerts commented on Feb 24, 2026

    @evertlammerts
    Member

    This happens in DuckDB core. Parser::ParseExpressionList() uses only the select list, and silently drops everything else. E.g. a filter will also be ignored, as long as it parses successfully:

    import duckdb
    duckdb.query("select unnest([0, 0, 1, 1]) as i, unnest([1, 2, 3, 4]) as x").aggregate("i, first(x) as x where things = 'bad'")
    

    Can you create an issue on core?

  2. jakkes commented on Feb 25, 2026

    @jakkes
    Author

    Sure

  3. jakkes commented on Feb 25, 2026

    @jakkes
    Author

    Created here: duckdb/duckdb#21072

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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