我试图弄清楚如何在 HIVE Metastore 中查询表和列注释(描述)。如果有办法将评论添加到 HIVE 表/列,不应该是一种查询/报告来自 HIVE Metastore 的评论的方法吗?
请帮忙 :)
最好的问候,迈克尔
我试图弄清楚如何在 HIVE Metastore 中查询表和列注释(描述)。如果有办法将评论添加到 HIVE 表/列,不应该是一种查询/报告来自 HIVE Metastore 的评论的方法吗?
请帮忙 :)
最好的问候,迈克尔
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;