配置单元创建表查询上的mismatchedtokenexception

2uluyalo  于 2021-05-30  发布在  Hadoop
关注(0)|答案(4)|浏览(670)

我正在尝试使用以下查询创建配置单元表:

CREATE TABLE IF NOT EXISTS BXDataSet 
    (ISBN STRING, 
    BookTitle STRING, 
    BookAuthor STRING, 
    YearOfPublication STRING, 
    Publisher STRING, 
    ImageURLS STRING, 
    ImageURLM STRING, 
    ImageURLL STRING) 
COMMENT 'BX-Books Table' 
ROW FORMAT DELIMITED FIELDS TERMINATED BY ';' LINE TERMINATED BY '\n'
STORED AS TEXTFILE;

当我提交到hive时,我得到了以下例外:

MismatchedTokenException(-1!=301)
    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:31433)
    at org.apache.hadoop.hive.ql.parse.HiveParser.rowFormatDelimited(HiveParser.java:30386)
    at org.apache.hadoop.hive.ql.parse.HiveParser.tableRowFormat(HiveParser.java:30662)
    at org.apache.hadoop.hive.ql.parse.HiveParser.createTableStatement(HiveParser.java:4683)
    at org.apache.hadoop.hive.ql.parse.HiveParser.ddlStatement(HiveParser.java:2144)
    at org.apache.hadoop.hive.ql.parse.HiveParser.execStatement(HiveParser.java:1398)
    at org.apache.hadoop.hive.ql.parse.HiveParser.statement(HiveParser.java:1036)
    at org.apache.hadoop.hive.ql.parse.ParseDriver.parse(ParseDriver.java:199)
    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:322)
    at org.apache.hadoop.hive.ql.Driver.compileInternal(Driver.java:975)
    at org.apache.hadoop.hive.ql.Driver.runInternal(Driver.java:1040)
    at org.apache.hadoop.hive.ql.Driver.run(Driver.java:911)
    at org.apache.hadoop.hive.ql.Driver.run(Driver.java:901)
    at org.apache.hadoop.hive.cli.CliDriver.processLocalCmd(CliDriver.java:268)
    at org.apache.hadoop.hive.cli.CliDriver.processCmd(CliDriver.java:220)
    at org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:423)
    at org.apache.hadoop.hive.cli.CliDriver.executeDriver(CliDriver.java:792)
    at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:686)
    at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:625)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.hadoop.util.RunJar.main(RunJar.java:212)
FAILED: ParseException line 10:43 mismatched input '<EOF>' expecting StringLiteral near 'BY' in table row format's field separator

如果配置单元安装正确,我就可以运行show tables之类的操作。那么,这个查询有什么问题?

tv6aics1

tv6aics11#

您需要指定分隔符的oct代码。
那是为了;华侨城代码是073

CREATE TABLE IF NOT EXISTS BXDataSet 
(ISBN STRING, 
BookTitle STRING, 
BookAuthor STRING, 
YearOfPublication STRING, 
Publisher STRING, 
ImageURLS STRING, 
ImageURLM STRING, 
ImageURLL STRING) 
COMMENT 'BX-Books Table' 
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\073' LINE TERMINATED BY '\n'
 STORED AS TEXTFILE;
pprl5pva

pprl5pva2#

答案很简单,就是逃避“;”像这样“\;”因此,您的行将是以“\;”结尾的行格式分隔字段以'\n'终止的行

sr4lhrrt

sr4lhrrt3#

create table if not exists bxdatasetnew(isbn string,booktitle string,bookauthor string,yearofpublication string,publisher string,imageurls string,imageurlm string,imageurll string)注解“bx books table”行格式分隔字段,以“\t”行终止,以“\n”行终止,存储为textfile;

epggiuax

epggiuax4#

错误的 LINE TERMINATED BY '\n' 正确的 LINES TERMINATED BY '\n' “行”不是“行”

相关问题