Querying JSON Data in Hive - returning null
Content of stock2.json file
{"myid":"0001","mytype":"donut"}
stock2.json file is in the path of '/warehouse/tablespace/external/hive/haijintest.db/stock2';
Below is the table creation script.
CREATE EXTERNAL TABLE stock4_json (myjson struct<myid:string, mytype:string>)ROW FORMAT SERDE 'org.apache.hive.hcatalog.data.JsonSerDe' LOCATION '/warehouse/tablespace/external/hive/haijintest.db/stock2';
Below is the query that returned null value.
0: jdbc:hive2://> select myjson.myid from stock4_json;
19/05/27 20:20:18 [103d2343-eb59-4072-8a07-5469b2112093 main]: WARN optimizer.SimpleFetchOptimizer: Table haijintest@stock4_json is external table, falling back to filesystem scan.
OK
+-------+
| myid |
+-------+
| NULL |
+-------+
1 row selected (0.232 seconds)
0: jdbc:hive2://> select * from stock4_json;
OK
+---------------------+
| stock4_json.myjson |
+---------------------+
| NULL |
+---------------------+
1 row selected (0.242 seconds)
Any suggestions?

