2
我是HIVE新手,需要一些帮助来查询我从JSON
文件创建的表格。EOF异常查询JSON上的Hive
CREATE TABLE json_table(json string);
LOAD DATA INPATH '/path/to/file.json'
INTO TABLE json_table;
当我查询创建json_table.json有:
SELECT * FROM json_table;
这将返回:
{"id":243379853,"sampling_rate":null,"timestamp":"2017-08-06 20:05:02","location":{"id":1296,"latitude":"49.863","longitude":"8.651","country":"DE"},"sensor":{"id":2573,"pin":"7","sensor_type":{"id":9,"name":"DHT22","manufacturer":"various"}},"sensordatavalues":[{"id":559959584,"value":"19.00","value_type":"temperature"},{"id":559959585,"value":"86.00","value_type":"humidity"}]}
我试图得到像
id | timestampt | | [...] |
==========|======================|=======|
243379853 | 2017-08-06 20:05:02 | [...] |
结果与查询
SELECT
GET_JSON_OBJECT(json_table.json,'$.id'),
GET_JSON_OBJECT(json_table.json,'$.timestamp')
GET_JSON_OBJECT(json_table.json,'$.sampling_rate')
GET_JSON_OBJECT(json_table.json,'$.location.latitude')
GET_JSON_OBJECT(json_table.json,'$.location.longitude')
FROM json_table;
,但我得到以下蜂巢SQL Exception
java.lang.Exception的:org.apache.hive.service.cli.HiveSQLException:错误在编译声明:失败:ParseException的线4:17失踪EOF在 '(' 近 'GET_JSON_OBJECT'