Skip to content
Advertisement

how to convert a column to an array in presto

Postgres provides a way to turn a column into an array. Samle query:

returns

How to do the same with Presto SQL?

Advertisement

Answer

Use array_agg(x [ORDER BY y]) aggregation function:

Result:

If you need array<int>, cast before aggregation: array_agg(cast(a as int))

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement