Hive建表异常cannot recognize input near ')' 'row' 'format' in column speci

2022-05-06 16:01:33 浏览数 (1)

有问题的建表语句

代码语言:javascript复制
hive> create table tb_emp0
    > (
    > id int,
    > name string,
    > )
    > row format delimited
    > fields terminated by ',';

错误信息

代码语言:javascript复制
NoViableAltException(307@[])
	at org.apache.hadoop.hive.ql.parse.HiveParser_IdentifiersParser.identifier(HiveParser_IdentifiersParser.java:10858)
	at org.apache.hadoop.hive.ql.parse.HiveParser.identifier(HiveParser.java:45850)
	at org.apache.hadoop.hive.ql.parse.HiveParser.columnNameType(HiveParser.java:38044)
	at org.apache.hadoop.hive.ql.parse.HiveParser.columnNameTypeList(HiveParser.java:36203)
	at org.apache.hadoop.hive.ql.parse.HiveParser.createTableStatement(HiveParser.java:5214)
	at org.apache.hadoop.hive.ql.parse.HiveParser.ddlStatement(HiveParser.java:2640)
	at org.apache.hadoop.hive.ql.parse.HiveParser.execStatement(HiveParser.java:1650)
	at org.apache.hadoop.hive.ql.parse.HiveParser.statement(HiveParser.java:1109)
	at org.apache.hadoop.hive.ql.parse.ParseDriver.parse(ParseDriver.java:202)
	at org.apache.hadoop.hive.ql.parse.ParseDriver.parse(ParseDriver.java:166)
	at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:396)
	at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:308)
	at org.apache.hadoop.hive.ql.Driver.compileInternal(Driver.java:1122)
	at org.apache.hadoop.hive.ql.Driver.runInternal(Driver.java:1170)
	at org.apache.hadoop.hive.ql.Driver.run(Driver.java:1059)
	at org.apache.hadoop.hive.ql.Driver.run(Driver.java:1049)
	at org.apache.hadoop.hive.cli.CliDriver.processLocalCmd(CliDriver.java:213)
	at org.apache.hadoop.hive.cli.CliDriver.processCmd(CliDriver.java:165)
	at org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:376)
	at org.apache.hadoop.hive.cli.CliDriver.executeDriver(CliDriver.java:736)
	at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:681)
	at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:621)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:483)
	at org.apache.hadoop.util.RunJar.run(RunJar.java:221)
	at org.apache.hadoop.util.RunJar.main(RunJar.java:136)
FAILED: ParseException line 5:0 cannot recognize input near ')' 'row' 'format' in column specification

错误原因 :

在修改表时 ,没有将建表语句完全修改正确

这是第一个表没问题

代码语言:javascript复制
create table tb_emp5
(
id int,
name string,
likes array<string>,  -- 爱好采用数组类型
address map<string,string> -- 地址采取map类型
)
row format delimited
fields terminated by ','
collection items terminated by '-'
map keys terminated by ':';

我在将第一个表修改成下面的出了问题!

代码语言:javascript复制
hive> create table tb_emp0
    > (
    > id int,
    > name string,
    > )
    > row format delimited
    > fields terminated by ',';

根据错误提示信息可知 : 无法识别第五行内容,说明第五行或第四行语法出了问题 FAILED: ParseException line 5:0 cannot recognize input near ‘)’ ‘row’ ‘format’ in column specification

最终发现了在name string,中在删减表时少删除了一个逗号 .导致读取时因为是逗号的原因系统无法认为第四行是结束, 因此读不到第五行的数据

0 人点赞