I have a hive table as
create table mySource(
col_1 map<string, string>,
col_2 map<string, string>
)
here is how a record might look like
col_1 col_2
{"a":1, "b":"2"} {"c":3, "d":"4"}
my target table looks like this
create table myTarget(
my_col map<string, string>
)
now i want to combine the two columns from mySource into a single map and feed it to my target table. Basically i want to write something like
insert into myTarget
select
some_method(col_1, col_2) as my_col
from mySource;
is there a built in method in hive that can do this ? I tried a few things with collect_set but got lots of errors
The solution using only built-in methods. Explode both maps, UNION ALL results, collect array of
key:value, concatenate array with',', convert string to map usingstr_to_map:Result:
With brickhouse library it would be much easier: