hive建表报错 FAILED: ParseException line 3:22 mismatched input ‘<EOF>‘ expecting StringLiteral near ‘by‘

错误

hive建表报错
FAILED: ParseException line 3:22 mismatched input ‘’ expecting StringLiteral near ‘by’ in table row format’s field separator

详细错误

在这里插入图片描述

建表语句

hive> create external table if not exists epidemicStatisticsData(dateRange string, numberOfAsymptomaticPeople int, cumulativeNumberOfConfirmedCases int, cumulativeNumberOfPeopleCured int, cumulativeNumberOfDeaths int)
    > row format delimited
    > fields terminated by ';'
    > stored as textfile
    > location '/usr/data/epidemicStatisticsData.txt';

终端报错

MismatchedTokenException(-1!=332)
	at org.antlr.runtime.BaseRecognizer.recoverFromMismatchedToken(BaseRecognizer.java:617)
	at org.antlr.runtime.BaseRecognizer.match(BaseRecognizer.java:115)
	at org.apache.hadoop.hive.ql.parse.HiveParser.tableRowFormatFieldIdentifier(HiveParser.java:36442)
	at org.apache.hadoop.hive.ql.parse.HiveParser.rowFormatDelimited(HiveParser.java:35352)
	at org.apache.hadoop.hive.ql.parse.HiveParser.tableRowFormat(HiveParser.java:35636)
	at org.apache.hadoop.hive.ql.parse.HiveParser.createTableStatement(HiveParser.java:5398)
	at org.apache.hadoop.hive.ql.parse.HiveParser.ddlStatement(HiveParser.java:2763)
	at org.apache.hadoop.hive.ql.parse.HiveParser.execStatement(HiveParser.java:1756)
	at org.apache.hadoop.hive.ql.parse.HiveParser.statement(HiveParser.java:1178)
	at org.apache.hadoop.hive.ql.parse.ParseDriver.parse(ParseDriver.java:204)
	at org.apache.hadoop.hive.ql.parse.ParseDriver.parse(ParseDriver.java:166)
	at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:404)
	at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:329)
	at org.apache.hadoop.hive.ql.Driver.compileInternal(Driver.java:1158)
	at org.apache.hadoop.hive.ql.Driver.runInternal(Driver.java:1253)
	at org.apache.hadoop.hive.ql.Driver.run(Driver.java:1084)
	at org.apache.hadoop.hive.ql.Driver.run(Driver.java:1072)
	at org.apache.hadoop.hive.cli.CliDriver.processLocalCmd(CliDriver.java:232)
	at org.apache.hadoop.hive.cli.CliDriver.processCmd(CliDriver.java:183)
	at org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:399)
	at org.apache.hadoop.hive.cli.CliDriver.executeDriver(CliDriver.java:776)
	at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:714)
	at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:641)
	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:498)
	at org.apache.hadoop.util.RunJar.run(RunJar.java:226)
	at org.apache.hadoop.util.RunJar.main(RunJar.java:141)
FAILED: ParseException line 3:22 mismatched input '<EOF>' expecting StringLiteral near 'by' in table row format's field separator

解决方案

更改建表语句中

fields terminated by ';'

fields terminated by '\073'

错误原因

由于笔者的hdfs文件中不同字段是通过分号分隔, 因此

fields terminated by ';'

但对于特殊字符,为避免产生歧义,hive 语法规定需通过asc码值对特殊字符进行转义
';'对应asc码值为'\073'
即改为

fields terminated by '\073'

对于其他字符对应的asc码值
ASCII码值表

原创不易
转载请标明出处
如果对你有所帮助 别忘啦点赞支持哈
在这里插入图片描述

  • 9
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

飞滕人生TYF

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值