2017-02-02 1 views
0

My Jsonは以下のとおりです。このJSONをハイブにロードして、いくつかの詳細をクエリする必要があります。NoViableAltException/PraseExceptionを与えるHIVEテーブルのJSONデータアップロード

{ 
    "id": "1234", 
    "pdid": "abcd", 
    "summary": { 
    "tripStartTimestamp": 1485263310528, 
    "tripEndTimestamp": 0, 
    "status": 10, 
    "totalGPSDistanceMetres": 0, 
    "avgGPSSpeed": 0, 
    "maxGPSSpeed": 0, 
    "avgInstMileage": 0, 
    "totalHaltTimeSeconds": 0, 
    "totalIdlingTimeSeconds": 0, 
    "totalRunningTimeMins": 0, 
    "startLocation": { 
     "latitude": 13.022425, 
     "longitude": 77.760587, 
     "speed": 70, 
     "ts": 1485263310528, 
     "direction": 0 
    }, 
    "endLocation": null, 
    "driverBehaviorSummary": [ 
     { 
     "driver": null, 
     "noOfRapidAcceleration": 0, 
     "noOfRapidDeceleration": 0, 
     "noOfOverSpeed": 0, 
     "noOfHarshBreak": 0 
     } 
    ] 
    }, 
    "latLongs": [ 
    { 
     "latitude": 13.022425, 
     "longitude": 77.760587, 
     "speed": 70, 
     "ts": 1485263310528, 
     "direction": 0 
    } 
    ], 
    "halts": [], 
    "idlings": [] 
} 

以下にHIVEのテーブルステートメントを作成しました。私はJSONスキーマを計算し、それを使って下の構造を作成しました。

CREATE TABLE TABLE_ABC_Test1(
    id string , 
    pdid string , 
    summary object<struct< 
    tripStartTimestamp:int, 
    tripEndTimestamp:int, 
    status:int, 
    totalGPSDistanceMetres:int, 
    avgGPSSpeed:int, 
    maxGPSSpeed:int, 
    avgInstMileage:int, 
    totalHaltTimeSeconds:int, 
    totalIdlingTimeSeconds:int, 
    totalRunningTimeMins:int, 
    startLocation object<struct< 
    latitude:int, 
    longitude:int, 
    speed:int, 
    ts:int, 
    direction:int>> 
    endLocation:string, 
    driverBehaviorSummary array<struct<object<struct< 
    driver:string, 
    noOfRapidAcceleration:int, 
    noOfRapidDeceleration:int, 
    noOfOverSpeed:int, 
    noOfHarshBreak:int 
    >>>> 
    >> 
    latLongs<array<struct<object< 
    latitude:int, 
    longitude:int, 
    speed:int, 
    ts:int, 
    direction:int 
    >>>> 
    halts<array<struct<>>> 
    idlings<array<struct<>>> 
    ) 
ROW FORMAT SERDE 
'org.apache.hive.hcatalog.data.JsonSerDe' 
STORED AS TEXTFILE; 

しかし、エラーのように来ている:

NoViableAltException([email protected][]) 
     .......some hive stack trace 
FAILED: ParseException line 4:10 cannot recognize input near 'object' '<' 'struct' in column type 

答えて

1

ハイブもあなたには、いくつかのフィールドの割り当てのための:来る欠けている、objectデータ型を持っていません。

create table構文は次のようになり、

CREATE TABLE TABLE_ABC_Test1(
    id string , 
    pdid string , 
    summary struct< 
    tripStartTimestamp:int, 
    tripEndTimestamp:int, 
    status:int, 
    totalGPSDistanceMetres:int, 
    avgGPSSpeed:int, 
    maxGPSSpeed:int, 
    avgInstMileage:int, 
    totalHaltTimeSeconds:int, 
    totalIdlingTimeSeconds:int, 
    totalRunningTimeMins:int, 
    startLocation:struct< 
    latitude:int, 
    longitude:int, 
    speed:int, 
    ts:int, 
    direction:int>, 
    endLocation:string, 
    driverBehaviorSummary:array<struct< 
    driver:string, 
    noOfRapidAcceleration:int, 
    noOfRapidDeceleration:int, 
    noOfOverSpeed:int, 
    noOfHarshBreak:int 
    >> 
    >, 
    latLongs array<struct< 
    latitude:int, 
    longitude:int, 
    speed:int, 
    ts:int, 
    direction:int 
    >>, 
    halts array<string>, 
    idlings array<string> 
    ) 
ROW FORMAT SERDE 
'org.apache.hive.hcatalog.data.JsonSerDe' 
STORED AS TEXTFILE; 
関連する問題