【大数据技术】hive3建表时报错ParseException line 11:0 missing EOF at ‘comment‘ near ‘‘/xxx‘‘经检查是因为语句顺序不当引起的

发布于:2023-02-14 ⋅ 阅读:(642) ⋅ 点赞:(0)

摘要:

【大数据技术】hive3建表是报错ParseException line 11:0 missing EOF at ‘comment’ near ‘’/xxx’'经检查是因为语句顺序不当引起的

过程:

原始代码如下

create  external table et1(
    id int comment 'ID' ,
    name string comment '姓名' ,
    addr array<string> comment '地址' ,
    hobby map<string,string> comment '爱好'
) row format delimited
fields terminated by ','
collection items terminated by '-'
map keys terminated by ':'
location '/xxx'
comment '信息表' ;

报错如下:
FAILED: ParseException line 11:0 missing EOF at ‘comment’ near ‘’/xxx’’
在这里插入图片描述
检查后,更改代码(将表的comment放到了location前面)如下,依然报错:
FAILED: ParseException line 10:0 missing EOF at ‘comment’ near ‘’:‘’

create  external table et1(
    id int comment 'ID' ,
    name string comment '姓名' ,
    addr array<string> comment '地址' ,
    hobby map<string,string> comment '爱好'
) row format delimited
fields terminated by ','
collection items terminated by '-'
map keys terminated by ':'
comment '信息表' 
location '/xxx' ;

在这里插入图片描述
最终更改代码如下,建表成功

create  external table et1(
    id int comment 'ID' ,
    name string comment '姓名' ,
    addr array<string> comment '地址' ,
    hobby map<string,string> comment '爱好'
) comment '信息表' 
row format delimited 
fields terminated by ','
collection items terminated by '-'
map keys terminated by ':' 
location '/xxx' ;

在这里插入图片描述

补充:

hive里的语法有严格限制,必须使用正确的顺序才能成功,附一张hive正确的语法图
在这里插入图片描述