rcongiu / Hive-JSON-Serde

Read - Write JSON SerDe for Apache Hive.
Other
732 stars 391 forks source link

Accessing map inside an map which has an map inside #174

Closed kirankvgit closed 7 years ago

kirankvgit commented 7 years ago

Hi

I do have the Json file which has map type with spaces in between keys and 3 levels of map for each key of root level map. How can I access the data elements which are at 3rd level of map. Any help would be appreciated.

thanks in advance best regards Kiran

rcongiu commented 7 years ago

-- data, save in maps.json
{"a": { "b" : { "c":{ "d": "HELLO!"}}}}

-- table 
 create table maps( a map<string, map<string,map<string,string>>>  )
     ROW FORMAT SERDE 'org.openx.data.jsonserde.JsonSerDe';
LOAD DATA LOCAL INPATH 'maps.json' OVERWRITE INTO TABLE maps;

-- this will work
select a['b']['c']['d'] from maps;
OK
HELLO!