Skip to content
Advertisement

Presto – Convert Table into Map

I would like to convert the below table into a map with multiple key/value pairs

label_a label_b
1 2
3 4
5 6

into

{‘label_a’ -> 1, ‘label_b’ -> 2}

{‘label_a’ -> 3, ‘label_b’ -> 4}

{‘label_a’ -> 5, ‘label_b’ -> 6}

What would be the easiest way to do this?

All the results I’ve found are scala/non-presto solutions and I’m not sure how it translates

Advertisement

Answer

You can construct a map with map_from_entries:

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