0
votes

I have a table Table1 with 5 coloumns and table 2 with 3 columns

DESCRIBE Table1;

col1 int
col2 int
col3 int
col4 int
col5 int

DESCRIBE Table2;

col1 int
col2 int
mapcol map<string, int>

I would now like to copy data from Table1 to Table2 where col3, col4,col5 would be stored in the mapcol as key value pairs. something like mapcol < col3:value_of_col3, col4:value_of_col4, col5:value_of_col5>

I tried copying directly using INSERT INTO from table 1 to table 2 but it didn't work.

The query I've used is something like this

INSERT INTO TABLE Table2 SELECT
t1.col1 AS col1,
t1.col2 AS col2,
t1.col3 AS mapcol ["col3"]
FROM Table1 t1

Logging initialized using configuration in file:/etc/hive/conf.dist/hive-log4j.properties
FAILED: NullPointerException null

Can someone help me on this please?

1

1 Answers

0
votes

Found a quick and dirty method for this one ! We can do this by using string_to_map function in hive. However, we will have to change the map to map in order to use string_to_map.