gpt4 book ai didi

hadoop - 不能在 Hive 表列名中使用 "."

转载 作者:可可西里 更新时间:2023-11-01 14:21:39 24 4
gpt4 key购买 nike

我正在使用 Hive 2.1.1 并尝试在列名称中使用 . 创建一个表:

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]

附言

我已经更新了文档(查找冒号) https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL

关于hadoop - 不能在 Hive 表列名中使用 ".",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43808435/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com