Hive ParseException - 无法识别“结束"“字符串"附近的输入 [英] Hive ParseException - cannot recognize input near 'end' 'string'

查看:62
本文介绍了Hive ParseException - 无法识别“结束"“字符串"附近的输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试从现有 DynamoDB 表创建 Hive 表时出现以下错误:

I am getting the following error when trying to create a Hive table from an existing DynamoDB table:

NoViableAltException(88@[])
at org.apache.hadoop.hive.ql.parse.HiveParser_IdentifiersParser.identifier(HiveParser_IdentifiersParser.java:9123)
at org.apache.hadoop.hive.ql.parse.HiveParser.identifier(HiveParser.java:30750)
...more stack trace...
FAILED: ParseException line 1:77 cannot recognize input near 'end' 'string' ',' in column specification

查询看起来像这样(为了保护无辜而简化):

The query looks like this (simplified to protect the innocent):

CREATE EXTERNAL TABLE moveProjects (cid string, end string, category string)
STORED BY 'org.apache.hadoop.hive.dynamodb.DynamoDBStorageHandler'
TBLPROPERTIES ("dynamodb.table.name" = "Projects",
    "dynamodb.column.mapping" = "cid:cid,end:end,category:category");

基本上,我正在尝试创建一个包含 Projects DynamoDB 表内容的 Hive 表,但是 create 语句从 Hive/Hadoop 引发了解析错误.

Basically, I am trying to create a Hive table containing the contents of the Projects DynamoDB table, but the create statement is throwing a parse error from Hive / Hadoop.

推荐答案

问题实际上不是语法错误,Hive ParseException 只是由 Hive 中的保留关键字引起的(在这种情况下,end).

The issue isn't actually a syntax error, the Hive ParseException is just caused by a reserved keyword in Hive (in this case, end).

解决方案:在有问题的列名周围使用反引号:

The solution: use backticks around the offending column name:

CREATE EXTERNAL TABLE moveProjects (cid string, `end` string, category string)
STORED BY 'org.apache.hadoop.hive.dynamodb.DynamoDBStorageHandler'
TBLPROPERTIES ("dynamodb.table.name" = "Projects",
    "dynamodb.column.mapping" = "cid:cid,end:end,category:category");

end 周围添加反引号后,查询按预期工作.

With the added backticks around end, the query works as expected.

IF、HAVING、WHERE、SELECT、UNIQUEJOIN、JOIN、ON、TRANSFORM、MAP、REDUCE、TABLESAMPLE、CAST、FUNCTION、EXTENDED、CASE、WHEN、THEN、ELSE、END、DATABASE、CROSS

IF, HAVING, WHERE, SELECT, UNIQUEJOIN, JOIN, ON, TRANSFORM, MAP, REDUCE, TABLESAMPLE, CAST, FUNCTION, EXTENDED, CASE, WHEN, THEN, ELSE, END, DATABASE, CROSS

来源:来自 Facebook Phabricator 跟踪器的这张 Hive 票

这篇关于Hive ParseException - 无法识别“结束"“字符串"附近的输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆