Cloudera Impala SQL TABLE CREATE,列名为方括号

时间:2015-03-25 13:02:41

标签: sql jdbc cloudera-cdh impala

我的声明是:

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

我运行CDH 5.3.0未修改,JDBC是类型4.1 v2.5.16.1018

澄清一下:我需要能够创建包含名称中包含方括号的列的表。

1 个答案:

答案 0 :(得分:2)

不幸的是hello_[3]不是有效的列名。这是Hive Metastore而非Impala的限制。

Impala使用Hive实用程序验证名称。这是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()。