作者热门文章
- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我的 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/
我有以下正则表达式 /[a-zA-Z0-9_-]/ 当字符串只包含从 a 到z 大小写、数字、_ 和 -。 我的代码有什么问题? 能否请您向我提供一个简短的解释和有关如何修复它的代码示例? //var
我是一名优秀的程序员,十分优秀!