简体   繁体   English

在表名称中使用连字符 (-) 创建 Hive 表

[英]Create Hive Table with hyphen (-) in Table Name

I need to create a table in Hive (v-1.2.2) with hyphen (-) in table name.我需要在 Hive (v-1.2.2) 中创建一个表,表名中带有连字符 (-)。

Reading Hive documentation , I tried to round table name with backticks (`) and it fails.阅读 Hive 文档,我试图用反引号 (`) 来圆表名称,但它失败了。

Query Executed查询已执行

CREATE EXTERNAL TABLE `kpisample_MarkContent_db786910-bd59-11e7-8329-9f28c9dd3095` STORED AS AVRO LOCATION '/prod/kpisample/dataset=0c253b00-2f04-11e6-ae13-d90f2a2beea0/KPI_id=MarkContent/year=2019/month=11/day=18/hour=4/' TBLPROPERTIES ('avro.schema.url'='/prod/schemas/kpisample/dataset=0c253b00-2f04-11e6-ae13-d90f2a2beea0/KPI_id=MarkContent/kpisetting_MarkContent.avsc');

Fail Message失败信息

FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. org.apache.hadoop.hive.ql.metadata.HiveException: [kpisample_MarkContent_db786910-bd59-11e7-8329-9f28c9dd3095]: is not a valid table name

Is there any way to do so?有什么办法吗?

Appreciate your help.感谢你的帮助。

Actually, table name containing - is not legitimate.实际上,包含-表名是不合法的。
The source code taken from org.apache.hadoop.hive.metastore.MetaStoreUtils shows that only characters , numbers and underscores are allowed in table names:来自org.apache.hadoop.hive.metastore.MetaStoreUtils的源代码显示表名中只允许使用字符数字下划线

/**
   * validateName
   *
   * Checks the name conforms to our standars which are: "[a-zA-z_0-9]+". checks
   * this is just characters and numbers and _
   * ...
   */
  static public boolean validateName(String name) {
    Pattern tpat = Pattern.compile("[\\w_]+");
    Matcher m = tpat.matcher(name);
    if (m.matches()) {
      return true;
    }
    return false;
  }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM