We will see how to query Nested JSON documents using HiveQL. Let's assume we want to access the following Sample-Json-complex.json file in HiveSample-Json-complex.json:
{"DocId":"Doc1","User1":{"Id":9192,"Username":"u2452","ShippingAddress":{"Address1":"6373 Sun Street","Address2":"apt 12","City":"Foster City","State":"CA"},"Orders":[{"ItemId":5343,"OrderDate":"12/23/2017"},{"ItemId":7362,"OrderDate":"12/24/2017"}]}}
Load Sample-Json-simple.json into HDFS:
[root@sandbox ~]# hadoop fs -mkdir /user/hive-complex-data/ [root@sandbox ~]# hadoop fs -put Sample-Json-complex.json /user/hive-complex-data/
Create an external Hive table, json_nested_table:
hive> CREATE ...