Я бы попробовал следующее
ваши данные
{"aa": {"a": "A","b": "B","c": "C","d": [{"d_1": "D-1","d_2": "D-2"}],"e": "E"},"bb": {"a": "AA","b": "BB","c": "CC","d": [{"d_1": "DD-11","d_2": "DD-22"}],"e": "EE"}}
оператор создания таблицы
CREATE TABLE my_table(aa struct<
a:string,
b:string,
c:string,
d:array<struct<
d_1:string,
d_2:string>>,
e:string>)
ROW FORMAT SERDE 'org.apache.hive.hcatalog.data.JsonSerDe'
STORED AS TEXTFILE
LOCATION '/user/training/json';
запрос таблицы
SELECT * FROM my_table;
+----------------------------------------------------+--+
| my_table.aa |
+----------------------------------------------------+--+
| {"a":"A","b":"B","c":"C","d":[{"d_1":"D-1","d_2":"D-2"}],"e":"E"} |
+----------------------------------------------------+--+
SELECT aa.a FROM my_table;
+----+--+
| a |
+----+--+
| A |
+----+--+
SELECT aa.d FROM my_table;
+------------------------------+--+
| d |
+------------------------------+--+
| [{"d_1":"D-1","d_2":"D-2"}] |
+------------------------------+--+
SELECT aa.d.d_1 FROM my_table;
+----------+--+
| d_1 |
+----------+--+
| ["D-1"] |
+----------+--+
Еще один хороший пример с более сложной структурой:
data: file2. json
{ "purchaseid": { "ticketnumber": "23546852222", "location": "vizag", "Travelerhistory": { "trav": { "fname": "ramu", "lname": "gogi", "travelingarea": { "destination": { "stationid": "KAJKL", "stationname": "hyd" } }, "food": { "foodpref": [{ "foodcode": "CK567", "foodcodeSegment": "NOVEG" }, { "foodcode": "MM98", "foodcodeSegment": "VEG" } ] } } } } }
оператор создания таблицы
CREATE TABLE my_table(
purchaseid STRUCT<ticketnumber:STRING,location:STRING,
Travelerhistory:STRUCT<
trav:STRUCT<fname:STRING,lname:STRING,
travelingarea:STRUCT< destination :STRUCT<stationid:string,stationname:string>>,
food :STRUCT<foodpref:ARRAY<STRUCT<foodcode:string,foodcodeSegment:string>>>
>>>)
ROW FORMAT SERDE 'org.apache.hive.hcatalog.data.JsonSerDe'
LOCATION '/user/training/json2/';
запрос к таблице
select purchaseid.ticketnumber from my_table;
select purchaseid.travelerhistory.trav.fname from my_table;
select purchaseid.travelerhistory.trav.lname from my_table;
and so on