Postgres `ARRAY_AGG(JSON_BUILD_OBJECT())` equivalent? Possible with `struct` SQL operator?
- Dominant language
- Rust
- Stars
- 9.3k
- Forks
- 2.4k
- Avg merge
- 3d 7h
- Merged PRs (30d)
- 344
Description
Curious whether it's possible to write SQL queries that do nested JSON selections in Datafusion.
IE, something like the below:
```sql
select json_agg(json_build_object(
'id', "houses"."id",
'address', "houses"."address",
'users', (
select json_agg(json_build_object(
'id', "users"."id",
'name', "users"."name"
))
from "users"
where "users"."house_id" = "houses"."id"
)
))
from "houses" as "houses"
```
Thank you =)
Contributor guide
Research direction
The issue provides no file, test, or entry point. Start by checking DataFusion's SQL support for JSON aggregation, struct operators, and correlated nested queries, then define the supported equivalent and add coverage for the supplied houses-and-users example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, sql
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100