KAs
KAs

Reputation: 1868

change one key-value in map columns in hive table via HQL

I have a Hive table whose schema is as below, the col is of map type:

select
    col
from table

col
{"name":"abc", "value":"val_1"}

What I need to do is change the val_1 to val_2 and create another table from it.

create table table_2 as
select
    col -- TODO: need to do something here
from table

Any suggestions? Thanks!

Upvotes: 0

Views: 1875

Answers (1)

David דודו Markovitz
David דודו Markovitz

Reputation: 44981

with t as (select map("name","abc","value","val_1") as col)
select  map("name",col["name"],"value","val_2") as col
from    t

+--------------------------------+
|              col               |
+--------------------------------+
| {"name":"abc","value":"val_2"} |
+--------------------------------+

Upvotes: 1

Related Questions