温馨提示:要看高清无码套图,请使用手机打开并单击图片放大查看。
Fayson的github:https://github.com/fayson/cdhproject
提示:代码块部分可以左右滑动查看噢
1.Hive的关键字
Hive有一些保留的关键字,我们在执行一些语句时,不能将这些关键字作为标识符(Identifier),比如建表语句的表名或者字段名,以下我们具体看看什么是Hive中的Identifier。
An Identifier can be a:
tableName
columnName
select expr alias
lateral view aliases
database name
view name
subquery alias
function name
ptf argument identifier
index name
property name for: db,tbl,partition…
fileFormat
role name
privilege name
principal name
macro name
hint name
window name
参考:
https://issues.apache.org/jira/secure/attachment/12618321/QuotedIdentifier.html
在Apache的Hive官网有关键字的列表,不同的Hive版本有一些区别。如下:
参考:
https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-Keywords,Non-reservedKeywordsandReservedKeywords
如果你非要使用“保留的关键字”作为标识符,官网也给出了建议:(1)对标识符使用倒引号(backtick);(2)set hive.support.sql11.reserved.keywords=false
2.CDH的Hive关键字测试
Fayson的测试环境是CDH5.13.1,Hive为1.1,以下我们以“DATE”关键字为例,做一下简单的测试。
1.分别创建字段为DATE的表test_keywords,以及表名为DATE的