单元上的MismatchedTokenException创建表查

单元上的MismatchedTokenException创建表查

本文介绍了配置单元上的MismatchedTokenException创建表查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  CREATE TABLE IF NOT EXISTS BXDataSet 
(ISBN STRING,
BookTitle STRING,
BookAuthor STRING,
YearOfPublication STRING,
发行商STRING,
ImageURLS STRING,
ImageURLM STRING,

COMMENT'BX-Books Table'
ROW FORMAT DELIMITED FIELDS'''''''终止''\\\
'
存储为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)
在org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:686)
在o rg.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在表行格式的字段分隔符中,输入'< EOF>'期望String'附近'BY' b $ b

Hive已正确安装,我可以运行诸如show tables之类的东西。那么,这个查询有什么问题?

解决方案

您需要指定分隔符的OCT代码。 b

就是说; OCT代码是073

  CREATE TABLE IF NOT EXISTS BXDataSet 
(ISBN STRING,
BookTitle STRING,
BookAuthor STRING,
YearOfPublication STRING,
发行商STRING,
ImageURLS STRING,
ImageURLM STRING,
ImageURLL STRING)
评论'BX-Books表'
行格式DELIMITED FIELDS'\073'行终止'\\\
'
作为TEXTFILE存储;


I'm trying to create a Hive table with the following query:

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;

How when I submitted to Hive I got the following exception:

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

Hive is correctly installed, I'm able to run things like show tables. So, what is the issue with this query?

解决方案

You need to specify delimiter's OCT code .

That is for ; OCT code is 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;

这篇关于配置单元上的MismatchedTokenException创建表查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 09:49