在 HIVE Metastore 中查询表和列注释
Posted
技术标签:
【中文标题】在 HIVE Metastore 中查询表和列注释【英文标题】:Query table and column comments in HIVE Metastore 【发布时间】:2018-07-24 21:25:46 【问题描述】:我正在尝试弄清楚如何在 HIVE Metastore 中查询表和列 cmets(描述)。如果有办法将 cmets 添加到 HIVE 表/列,不应该是一种从 HIVE Metastore 查询/报告 cmets 的方法吗?
请帮忙:)
最好的问候, 迈克尔
【问题讨论】:
【参考方案1】:SELECT DBS.NAME AS OWNER,
TBLS.TBL_NAME as OBJECT_NAME,
TBL_COMMENTS.TBL_COMMENT as OBJECT_DESCRIPTION,
TBLS.TBL_ID as OBJECT_ID,
TBLS.TBL_TYPE as OBJECT_TYPE,
'VALID' as OBJECT_STATUS,
COLUMNS_V2.COLUMN_NAME,
COLUMNS_V2.COMMENT as COLUMN_DESCRIPTION,
COLUMNS_V2.TYPE_NAME AS DATA_TYPE,
'Y' as NULL_IND,
'N' as PRIMARY_KEY_IND,
TBLS.CREATE_TIME as LAST_DDL_TIME
FROM DBS
JOIN TBLS
ON DBS.DB_ID = TBLS.DB_ID
JOIN SDS
ON TBLS.SD_ID = SDS.SD_ID
JOIN COLUMNS_V2
ON COLUMNS_V2.CD_ID = SDS.CD_ID
JOIN (SELECT DISTINCT
TBL_ID,
TBL_COMMENT
FROM (SELECT TBLS.TBL_ID TBL_ID,
TABLE_PARAMS.PARAM_KEY,
TABLE_PARAMS.PARAM_VALUE,
CASE WHEN TABLE_PARAMS.PARAM_KEY = 'comment'
THEN TABLE_PARAMS.PARAM_VALUE
ELSE ''
END TBL_COMMENT
FROM TBLS
JOIN TABLE_PARAMS
ON TBLS.TBL_ID = TABLE_PARAMS.TBL_ID) TBL_COMMENTS_INTERNAL) TBL_COMMENTS
ON TBLS.TBL_ID = TBL_COMMENTS.TBL_ID;
【讨论】:
以上是关于在 HIVE Metastore 中查询表和列注释的主要内容,如果未能解决你的问题,请参考以下文章