简体   繁体   中英

How to break a row into multiple rows based on a column value in Athena (Presto)?

I have a Athena table that has a column containing array of values. I want to create multiple rows from one row such that the column of array can be changed to contain only 1 value.

Eg :

Name   Id   PhoneNumber
Josh   123  [1236348475,5323794875]

to look like :

Name   Id   PhoneNumber
Josh   123  1236348475
Josh   123  5323794875

How can I write my query to achieve this?

I think unnest() does what you want:

select t.name, t.id, u.phonenumber
from t cross join
     unnest(t.phonenumber) u(phonenumber);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM