cloudera impala sql表在列名中用方括号创建

vaqhlq81  于 2021-06-26  发布在  Impala
关注(0)|答案(1)|浏览(524)

我的声明如下:

CREATE TABLE my_table (`hello_[3]` INT)

当我尝试通过jdbc或从hue运行它时,我得到:


**AnalysisException: Invalid column/field name: hello_[3]**

尝试其他引用方法会得到相同的结果: CREATE TABLE my_table ('hello_[3]' INT) ^ encountered: string literal expected: identifier CREATE TABLE my_table ("hello_[3]" INT) ^ encountered: string literal expected: identifier CREATE TABLE my_table ([hello_[3]]] INT) ^ encountered: [ expected: identifier 我运行的是未经修改的cdh5.3.0,jdbc的类型是4.1v2.5.16.1018
澄清一下:我需要能够创建名称中包含方括号的列的表。

clj7thdc

clj7thdc1#

不幸的是 hello_[3] 不是有效的列名。这是Hive元存储的限制,而不是 Impala 。
impala使用配置单元实用程序验证名称。这就是columndesc.java中分析失败的地方:

public void analyze() throws AnalysisException {
    // Check whether the column name meets the Metastore's requirements.
    if (!MetaStoreUtils.validateName(colName_)) {
      throw new AnalysisException("Invalid column/field name: " + colName_);
    }
    type_.analyze();
  }

有关详细信息,请参见metastoreutils.validatename()。

相关问题