Closed
Description
Is your feature request related to a problem or challenge?
Follow on to #6384
It would be nice to implement unnest
function (with the properties like the analog in PostgreSQL) in arrow-datafusion
.
Describe the solution you'd like
Main benefits for adding this feature:
- With
unnest
function we can use aggregate functions for arrays:
SELECT sum(a) AS total FROM (SELECT unnest(make_array(3, 5, 6) AS a) AS b;
----
14
unnest
function serves as an exchange between arrays and columns, we have 2 cases of behavior:
unnest
with single argumentunnest
with multiple argument (more than 1) (this form is only allowed in a query's FROM clause)
Examples:
unnest(make_array(1, 2))
----
1
2
select * from unnest(make_array(1, 2, 3), make_array('h', 'e', 'l', 'l', 'o')
----
1 h
2 e
3 l
l
o
Describe alternatives you've considered
For aggregate functions, we can create a lot of individual functions for aggregate functions (like array_sum
), but I think this implementation would be too redundant.
Additional context
Similar Issues:
#6119
Links to sources:
https://www.postgresql.org/docs/current/functions-array.html