· 8 years ago · Mar 15, 2018, 08:18 PM
1CREATE EXTERNAL TABLE IF NOT EXISTS test (
2 timestamp double,
3 stats array<struct<time:double, mean:double, var:double>>,
4 dets array<struct<coords: array<double>, header:struct<frame:int,
5 seq:int, name:string>>>,
6 pos struct<x:double, y:double, theta:double>
7)
8ROW FORMAT SERDE 'org.openx.data.jsonserde.JsonSerDe'
9WITH SERDEPROPERTIES ('ignore.malformed.json'='true')
10LOCATION 's3://test-bucket/test-folder/'
11
12{"timestamp":1520640777.666096,"stats":[{"time":15,"mean":45.23,"var":0.31},{"time":19,"mean":17.315,"var":2.612}],"dets":[{"coords":[2.4,1.7,0.3], "header":{"frame":1,"seq":1,"name":"hello"}}],"pos": {"x":5,"y":1.4,"theta":0.04}}
13
14select * from test
15
16"timestamp","stats","dets","pos"
17"1.520640777666096E9","[{time=15.0, mean=45.23, var=0.31}, {time=19.0, mean=17.315, var=2.612}]","[{coords=[2.4, 1.7, 0.3], header={frame=1, seq=1, name=hello}}]","{x=5.0, y=1.4, theta=0.04}"
18
19SELECT timestamp, cast(stats as JSON) as stats, cast(dets as JSON) as dets, cast(pos as JSON) as pos FROM "sampledb"."test"
20
21"timestamp","stats","dets","pos"
22"1.520640777666096E9","[[15.0,45.23,0.31],[19.0,17.315,2.612]]","[[[2.4,1.7,0.3],[1,1,""hello""]]]","[5.0,1.4,0.04]"