gpt4 book ai didi

HIVE 表中的 JSON 数据上传给出 NoViableAltException/PraseException

转载 作者:可可西里 更新时间:2023-11-01 16:40:26 27 4
gpt4 key购买 nike

我的 Json 在下面。我必须将此 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(26@[])
.......some hive stack trace
FAILED: ParseException line 4:10 cannot recognize input near 'object' '<' 'struct' in column type

最佳答案

Hive 没有 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;

关于HIVE 表中的 JSON 数据上传给出 NoViableAltException/PraseException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41996045/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com