如何在蜂巢中的驼峰式情况下保留列名 [英] How to keep Column Names in camel case in hive

查看:87
本文介绍了如何在蜂巢中的驼峰式情况下保留列名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

选择"12345"作为"EmpId";

select '12345' as `EmpId';

-输出的是空值12345

-- output is empid with value 12345

任何人都可以保持与EmpId相同的列名吗?

Any leads to keep the same columnname as EmpId?

推荐答案

不可能.这是HIVE metastore的局限性.它以小写形式存储表的架构.

Not possible. This is a limitation of the HIVE metastore. It stores the schema of a table in all lowercase.

Hive使用此方法来规范化列名,请参见

Hive uses this method to normalize column names, see Table.java

private static String normalize(String colName) throws HiveException {
    if (!MetaStoreServerUtils.validateColumnName(colName)) {
      throw new HiveException("Invalid column name '" + colName
          + "' in the table definition");
    }
    return colName.toLowerCase();
  }

所有代码中都有很多相同的toLowerCase.例如 SessionHiveMetaStoreClient.java 等,由于更改所需的代码太多,要更改此行为似乎并不容易.

There are a lot of the same toLowerCase across all the code. For example SessionHiveMetaStoreClient.java, etc, etc, and it seems it's not easy to change this behaviour because of so many changes in the code required.

这篇关于如何在蜂巢中的驼峰式情况下保留列名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆