0

I have a table with column whose type is map<string,string>. Now I have requirement where I want to remove specific key say "xyz" from this map and keep map as it is in table. If we just want to retrieve keys we can use Lateral view but I want to remove specific key xyz permanently.

How do we solve this?

halfer
  • 19,824
  • 17
  • 99
  • 186
Umesh K
  • 13,436
  • 25
  • 87
  • 129

1 Answers1

0

As hive (any hadoop ) does not support update on table data (document on hdfs).

So there is work around .

Use Lateral view explode and remove the key value from result set

Str_to_map with group by create data in map format

you can have a view on above logic or do out put result and create a table on top of this output files.

removing key example (map explode example )

        with result  as (select key1, value1  from test2 
              lateral view explode(item1) dummy1 as key1, value1

          select * from result   where key1 !='1'
Community
  • 1
  • 1
sandeep rawat
  • 4,797
  • 1
  • 18
  • 36
  • Hi thanks I did not understand can you please give me example how do I remove specific key in a map and keep map in a table with removed specific keys. – Umesh K Jul 23 '16 at 13:32
  • OK thanks I am still confused will lateral view and explode remove specific key permanently from main table? – Umesh K Jul 23 '16 at 14:18
  • as i told u can not update data in hdfs u have to create result set and do output that in csv and use this file for new table.. – sandeep rawat Jul 23 '16 at 14:20