GlareDB / glaredb

GlareDB: An analytics DBMS for distributed data
https://glaredb.com
MIT License
721 stars 41 forks source link

feat: UNNEST in select list #3311

Closed scsmithr closed 3 days ago

scsmithr commented 4 days ago

Initial UNNEST support.

Basic list unnest:

>> SELECT unnest([3,4,5]);
┌────────┐
│ unnest │
│ Int32  │
├────────┤
│      3 │
│      4 │
│      5 │
└────────┘

Unnests with different list lengths:

>> SELECT unnest([3,4,5]), unnest([3,2]);
┌────────┬────────┐
│ unnest │ unnest │
│ Int32  │ Int32  │
├────────┼────────┤
│      3 │      3 │
│      4 │      2 │
│      5 │   NULL │
└────────┴────────┘

Aggregate list values using unnest:

>> SELECT sum(unnest(a)), min(unnest(a)), max(unnest(a)) FROM VALUES ([1,2,3]), ([4,5,6]) v(a);
┌───────┬───────┬───────┐
│ sum   │ min   │ max   │
│ Int64 │ Int32 │ Int32 │
├───────┼───────┼───────┤
│    21 │     1 │     6 │
└───────┴───────┴───────┘