My use case is as following:
I want to copy data from Table-A to Table-B and transform field1 from array of struct to array of string where the string is the val1 property of struct in table-A and ignore val2.
Table-A:
field1: array<struct<val1: str, val2: int>>
sample data:
[{val1: "abc", val2: 123}, {val1: "def", val2: 456}], [{val1: "xyz", val2: 789}]
Table-B:
field1: array<string>
sample data:
["abc", "def"], ["xyz"]
I am not able to figure out how I can select the field1 column with transformation on it through hive query language.
The things I was able to figure out was I could explode the array, perform a select of the val1 and then do collect_list but after trying multiple times could not get the correct syntax.
My query was like:
select collect_list(select col.val1
from explode(field1) as col) from table-A
I also want to strictly do it through hiveql and not through a udf in python.
Thank you.