I have HIVE-table with 2 columns (string, array<struct<type=string, cnt=int>>) like this:
||id || params ||
|| id1 || [{type=A, cnt=4}, {type=B, cnt=2}]
|| id2 || [{type=A, cnt=3}, {type=C, cnt=1}, {type=D, cnt=0}]
|| id3 || [{type=E, cnt=1}]
I need to transform it to table with separated int columns, where columns name are 'types' and values are equal to cnt:
|| id || A || B || C || D || E ||
|| id1 || 4 || 2 || NULL || NULL || NULL ||
|| id2 || 3 || NULL || 1 || 0 || NULL ||
|| id3 || NULL || NULL || NULL || NULL || 1 ||
What is the best and effective way to transform table? Both in Spark SQL and PySpark style. Thank you.