I have a big database with 1.7 million rows. One column is a list generated by a collect_set
. I would like to explode this list into a 1/0 boolean table
PIVOT is not supported by Hive at the moment, so no answer using this function can be accepted.
Table I have:
id | list_center |
-----|------------------------------------------|
0788 | [] |
0568 | ["Lorem"] |
0879 | ["Lorem","ipsum"] |
0025 | ["who", "exercise", "train"] |
0365 | ["ipsum", "airplane", "tariff", "lorem"] |
Expected result:
id | lorem | ipsum | who | exercise | train | airplane | tariff |
-----|-------|--------|-----|----------|-------|----------|--------|
0788 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
0568 | 1 | 0 | 0 | 0 | 0 | 0 | 0 |
0879 | 1 | 1 | 0 | 0 | 0 | 0 | 0 |
0025 | 0 | 0 | 1 | 1 | 1 | 0 | 0 |
0365 | 1 | 1 | 0 | 0 | 0 | 1 | 1 |