Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]
Created 05-28-2019 03:28 AM
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?
Created 05-28-2019 07:41 AM
Hi @Haijin Li
The input file you are using is incorrect stock2.json
{"myid":"0001","mytype":"donut"}command is correct
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';
myjson struct define it is having further list and map.
You have to place correct input file stock3.json
{"myjson":{"myid":"0001","mytype":"donut"}}and create table with same command and check.
Let me know if still you are facing issue.
Regards,
Vinay K
Created 05-28-2019 07:41 AM
Hi @Haijin Li
The input file you are using is incorrect stock2.json
{"myid":"0001","mytype":"donut"}command is correct
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';
myjson struct define it is having further list and map.
You have to place correct input file stock3.json
{"myjson":{"myid":"0001","mytype":"donut"}}and create table with same command and check.
Let me know if still you are facing issue.
Regards,
Vinay K
Created 05-28-2019 05:13 PM