Closed timeforce closed 7 years ago
hi having same issue
So, I tried the code above...a few things.
create table json_81(
lastTimestamp string,
obj array<struct<
description:string,
ts:string,prefix:string,
encoding:string>>,
success string,
totalResults string,
elapsedms string)
ROW FORMAT SERDE 'org.openx.data.jsonserde.JsonSerDe'
WITH SERDEPROPERTIES ( "mapping.ts" = "timestamp" ) ;
see how I replaced 'timestamp' with 'ts' and added the mapping in the serde properties.
hive> select * from json_81;
OK
xxxxxxx [{"description":"xxxxx","ts":"xxxxxxxx","prefix":"xxx","encoding":"xxxx"}] NULL xxx xxx
Closing as no answer to my observation.
my json file is like: {"lastTimestamp": xxxxxxx, "obj":[{"description":"xxxxx", "timestamp": xxxxxxxx, "prefix":"xxx", "tags":{}, "encoding":"xxxx"}], "sucess":"xxxx", "totalResults":"xxx", "elapsedms":"xxx"}
And I tried:
hive> create table json(lastTimestamp string, obj array<struct<description:string, timestamp:string,prefix:string, encoding:string>>, success string,totalResults string,elapsedms string)
But got error:
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. Could not initialize class org.openx.data.jsonserde.objectinspector.JsonObjectInspectorFactory
I omitted "tags":{} as I don't know how to deal with it in the schema. Is that the root cause?
Thanks