不能使用“.”在 Hive table 列名中
Cannot use a "." in a Hive table column name
我正在使用 Hive 2.1.1
,我正在尝试创建一个 table,在列名称中包含 .
:
CREATE TABLE `test_table`(
`field.with.dots` string
);
当我这样做时,我得到:
FAILED: ParseException line 4:0 Failed to recognize predicate ')'. Failed rule: '[., :] can not be used in column name in create table statement.' in column specification
我一定是做错了什么,因为 hive documentation 说:
In Hive release 0.13.0 and later, by default column names can be specified within backticks (`) and contain any Unicode character (HIVE-6013)
.
是一个 unicode 字符。知道我在做什么吗?
为了给您更多上下文,这是在 Amazon EMR 5.5.0 集群上进行的。谢谢!
源代码:HiveParser
...
private char [] excludedCharForColumnName = {'.', ':'};
...
private CommonTree throwColumnNameException() throws RecognitionException {
throw new FailedPredicateException(input, Arrays.toString(excludedCharForColumnName) + " can not be used in column name in create table statement.", "");
}
Jira 票证:Disallow create table with dot/colon in column name
请注明动机:
Since we don't allow users to query column names with dot in the
middle such as emp.no, don't allow users to create tables with such
columns that cannot be queried
似乎 create table
被处理了,但 CTAS
和 ALTER TABLE...
都没有
hive> create table t as select 1 as `a.b.c`;
OK
hive> desc t;
OK
col_name data_type comment
a.b.c int
Time taken: 0.441 seconds, Fetched: 1 row(s)
hive> select * from t;
FAILED: RuntimeException java.lang.RuntimeException: cannot find field a from [0:a.b.c]
hive> create table t (i int);
OK
hive> alter table t change column i `a.b.c` int
hive> select * from t;
Error while compiling statement: FAILED: RuntimeException java.lang.RuntimeException: cannot find field a from [0:a.b.c]
P.s.
我更新了文档(寻找colon
)
https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL
我正在使用 Hive 2.1.1
,我正在尝试创建一个 table,在列名称中包含 .
:
CREATE TABLE `test_table`(
`field.with.dots` string
);
当我这样做时,我得到:
FAILED: ParseException line 4:0 Failed to recognize predicate ')'. Failed rule: '[., :] can not be used in column name in create table statement.' in column specification
我一定是做错了什么,因为 hive documentation 说:
In Hive release 0.13.0 and later, by default column names can be specified within backticks (`) and contain any Unicode character (HIVE-6013)
.
是一个 unicode 字符。知道我在做什么吗?
为了给您更多上下文,这是在 Amazon EMR 5.5.0 集群上进行的。谢谢!
源代码:HiveParser
...
private char [] excludedCharForColumnName = {'.', ':'};
...
private CommonTree throwColumnNameException() throws RecognitionException {
throw new FailedPredicateException(input, Arrays.toString(excludedCharForColumnName) + " can not be used in column name in create table statement.", "");
}
Jira 票证:Disallow create table with dot/colon in column name
请注明动机:
Since we don't allow users to query column names with dot in the middle such as emp.no, don't allow users to create tables with such columns that cannot be queried
似乎 create table
被处理了,但 CTAS
和 ALTER TABLE...
hive> create table t as select 1 as `a.b.c`;
OK
hive> desc t;
OK
col_name data_type comment
a.b.c int
Time taken: 0.441 seconds, Fetched: 1 row(s)
hive> select * from t;
FAILED: RuntimeException java.lang.RuntimeException: cannot find field a from [0:a.b.c]
hive> create table t (i int);
OK
hive> alter table t change column i `a.b.c` int
hive> select * from t;
Error while compiling statement: FAILED: RuntimeException java.lang.RuntimeException: cannot find field a from [0:a.b.c]
P.s.
我更新了文档(寻找colon
)
https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL