duckdb / duckdb

DuckDB is an analytical in-process SQL database management system
http://www.duckdb.org
MIT License
22.43k stars 1.79k forks source link

aggregate(df).* is a syntax error but should be unnest(aggregate(df)) #13055

Open soerenwolfers opened 1 month ago

soerenwolfers commented 1 month ago

What happens?

From my understanding of https://duckdb.org/docs/sql/expressions/star.html#struct, I should be able to apply struct.* anywhere, including on the result of an aggregate.

To Reproduce

FROM (
    SELECT unnest(range(10)) % 3, random(), random()
) df(id, value1, value2)
SELECT first(df).*
GROUP BY id

throws

 Parser Error: syntax error at or near "*"

but should do the same as

FROM (
   SELECT unnest(range(10)) % 3, random(), random()
) df(id, value1, value2)
SELECT unnest(first(df))
GROUP BY id
┌───────┬──────────────────────┬─────────────────────┐
│  id   │        value1        │       value2        │
│ int64 │        double        │       double        │
├───────┼──────────────────────┼─────────────────────┤
│     0 │   0.9082586837466806 │    0.83812924195081 │
│     2 │ 0.007013199618086219 │   0.957239514682442 │
│     1 │  0.03558909869752824 │ 0.07476666080765426 │
└───────┴──────────────────────┴─────────────────────┘

OS:

Linux

DuckDB Version:

1.0.0

DuckDB Client:

Python

Full Name:

Soeren Wolfers

Affiliation:

G-Research

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?

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

hannes commented 1 month ago

Thanks for reporting, indeed its odd that that does not work