如何add/edit Hive table 中分区列的注释?
How to add/edit the comment of a partitioned column in Hive table?
我有一个 Hive table,在列 'part_col' 上进行了分区,我想向该列 'part_col' 添加评论。
我尝试了下面的 ALTER 语句,但它不起作用并抛出错误,
ALTER TABLE comment_test PARTITION (part_col) RENAME TO PARTITION (part_col string COMMENT 'new_comment');
是否有任何其他方法来添加或修改 Hive table 列的分区?
- 可以在创建 table 时将注释添加到分区列。 (如例[1]所示)。
- 由于 Hive 分区设计的性质,需要在元数据数据库中添加或修改分区列的注释。
ALTER
语句可用于更改分区列的值,例如示例 [2],但不能更改分区本身的名称。
[1] 创建分区时的注释 table:
CREATE TABLE comment_test
(id STRING COMMENT 'comment1',
description STRING COMMENT 'comment2')
PARTITIONED BY (part_col STRING COMMENT 'partition_comment');
[2] 修改分区值的语句。 (不是分区列名)
ALTER TABLE comment_test
PARTITION (part_col='501') RENAME TO PARTITION (part_col='503');
[3] 在 table 创建后查询 add/modify 分区注释。 (在 HMS 后端数据库中 运行 而不是在 Hive 中)
UPDATE PARTITION_KEYS
SET PKEY_COMMENT='new_comment'
WHERE TBL_ID=<TBL_ID of the table of interest> ;
要获取 TBL_ID,运行 HMS 后端数据库中的以下查询,
SELECT TBL_ID
FROM TBLS
WHERE TBL_NAME='<name of the table for which the partition change is needed>';
我有一个 Hive table,在列 'part_col' 上进行了分区,我想向该列 'part_col' 添加评论。
我尝试了下面的 ALTER 语句,但它不起作用并抛出错误,
ALTER TABLE comment_test PARTITION (part_col) RENAME TO PARTITION (part_col string COMMENT 'new_comment');
是否有任何其他方法来添加或修改 Hive table 列的分区?
- 可以在创建 table 时将注释添加到分区列。 (如例[1]所示)。
- 由于 Hive 分区设计的性质,需要在元数据数据库中添加或修改分区列的注释。
ALTER
语句可用于更改分区列的值,例如示例 [2],但不能更改分区本身的名称。
[1] 创建分区时的注释 table:
CREATE TABLE comment_test
(id STRING COMMENT 'comment1',
description STRING COMMENT 'comment2')
PARTITIONED BY (part_col STRING COMMENT 'partition_comment');
[2] 修改分区值的语句。 (不是分区列名)
ALTER TABLE comment_test
PARTITION (part_col='501') RENAME TO PARTITION (part_col='503');
[3] 在 table 创建后查询 add/modify 分区注释。 (在 HMS 后端数据库中 运行 而不是在 Hive 中)
UPDATE PARTITION_KEYS
SET PKEY_COMMENT='new_comment'
WHERE TBL_ID=<TBL_ID of the table of interest> ;
要获取 TBL_ID,运行 HMS 后端数据库中的以下查询,
SELECT TBL_ID
FROM TBLS
WHERE TBL_NAME='<name of the table for which the partition change is needed>';