hive - 对 hive 和 Metastore 的查询
问题描述
我想通过查询获取每列的列名和最小/最大值。
假设我只知道表的名称。
我知道以下查询。
表名=人
select min(some_col_name_which_don't_know) from people
SELECT t.TBL_ID, d.NAME as `schema`, t.TBL_NAME name, t.TBL_TYPE, tp.PARAM_VALUE as description,
p.PKEY_NAME as col_name, p.INTEGER_IDX as col_sort_order,
p.PKEY_TYPE as col_type, p.PKEY_COMMENT as col_description, 1 as "is_partition_col",
IF(t.TBL_TYPE = 'VIRTUAL_VIEW', 1, 0) "is_view"
FROM TBLS t
JOIN DBS d ON t.DB_ID = d.DB_ID
JOIN PARTITION_KEYS p ON t.TBL_ID = p.TBL_ID
WHRER TBL_NAME=people
我可以将这两个查询合并为一个查询吗?
蜂巢中有没有像 information_schema 这样的表?
解决方案
可能重复:Hive,我如何检索所有数据库的表列
您可以使用以下命令列出表中的总列数:
hive -e "show columns in <table name>" > table_list.txt
下一步是遍历 table_list.txt 文件并构建一个包含所有字段名称及其最大/最小查询的查询字符串。
for column in table_list:
hive -e "select min("+column+") from <table name>" >> min_max_table.txt
希望这可以帮助。
推荐阅读
- php - 如何使用 PHP 将 Nav webservice 生成的 odata 访问到 html 布局中
- javascript - Firebase PERMISSION_DENIED 没有数据库的推送通知
- git - 如果我们提交已经在远程仓库中的东西会发生什么
- c# - MultipleActiveResultSets=True 在调用存储过程时没有给出正确的结果
- django - 如何在 django-allauth 中自定义社交帐户模型
- c# - 序列包含几个元素 Dapper
- c# - 哪种方法更好,2 个存储过程调用或一个大调用并仅过滤列表?
- angular - NgClass: if array contains item
- python - How to remove option selected with bs4?
- r - 如何从 shapefile 传单 R 访问多边形信息