I am facing some problem while querying HIVE
CREATE TABLE json_table( json string);
LOAD DATA INPATH '/path/to/file.json'
INTO TABLE json_table;
When I query the created json_table.json with:
SELECT * FROM json_table;
This returns:
{"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"}]}
I'm trying to get a result similar to this
id | timestampt | | [...] |
==========|======================|=======|
243379853 | 2017-08-06 20:05:02 | [...] |
with the query
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;
But i get the following Hive SQL Exception
java.lang.Exception: org.apache.hive.service.cli.HiveSQLException: Error while compiling statement: FAILED:ParseException line 4:17 missing EOF at '(' near 'GET_JSON_OBJECT'