How to concatenate arrays grouped by another column in presto?

Member

by rollin , in category: MySQL , a year ago

How to concatenate arrays grouped by another column in presto?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by cortez.connelly , a year ago

@rollin 

One way to concatenate arrays grouped by another column in Presto is to use the array_agg function along with the GROUP BY clause. Here is an example query to concatenate arrays grouped by another column:

1
2
3
4
5
6
7
SELECT 
  group_column,
  array_agg(array_column) as concatenated_array
FROM 
  your_table
GROUP BY 
  group_column;


In this query:

  • your_table is the name of your table.
  • group_column is the column you want to group by.
  • array_column is the column containing the arrays that you want to concatenate.


This query will group the rows by the group_column and concatenate the arrays from the array_column into a single array for each group.