[英]Check if a hive table is partitioned on a given column
I have a list of hive tables , of which some are partitioned. 我有一个蜂巢表的列表,其中一些是分区的。 Given a column I need to check if a particular table is partitioned on that column or not. 给定一列,我需要检查特定的表是否在该列上进行了分区。 I have searched and found that desc formatted tablename would result in all the details of the table. 我搜索发现,以desc格式格式化的表名将导致表的所有详细信息。 Since I have to iterate over all the tables and get the list , desc formatted would not help. 由于我必须遍历所有表并获取列表,因此将desc格式化将无济于事。 Is there any other way this can be done. 还有其他方法可以做到这一点。
You can connect directly to metastore and query it: 您可以直接连接到metastore并对其进行查询:
metastore=# select d."NAME" as DATABASE,
t."TBL_NAME" as TABLE,
p."PKEY_NAME" as PARTITION_KEY
from "PARTITION_KEYS" p
join "TBLS" t on p."TBL_ID"=t."TBL_ID"
join "DBS" d on t."DB_ID"=d."DB_ID";
database | table | partition_key
----------+-------------+---------------
default | src_union_1 | ds
default | cbo_t1 | dt
default | cbo_t2 | dt
The exact syntax of querying your metastore depends on your particular choice of metastore (in my case is a PostgreSQL one). 查询元存储库的确切语法取决于您对元存储库的特定选择(在我的情况下是PostgreSQL)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.