Reply
Highlighted
Explorer
Posts: 36
Registered: ‎02-01-2017
Accepted Solution

Add comments to columns in an impala table

How do I add comments to a column in an impala table for specific columns after creating it.

 

Thanks

Posts: 394
Topics: 11
Kudos: 60
Solutions: 35
Registered: ‎09-02-2016

Re: Add comments to columns in an impala table

@gimp077

 

I didn't get a chance to test it, but just try this, it may help

 

Go to Hue -> Metastore manager -> db.table -> property -> update comment

Cloudera Employee
Posts: 219
Registered: ‎03-23-2015

Re: Add comments to columns in an impala table

ALTER TABLE test CHANGE {columname} {columnname} {datatype} comment 'test comment';


See below test case:

 

[impala-host:21000] > show create table test;
Query: show create table test
+---------------------------------------------------------------------------------------------------------------------+
| result                                                                                                              |
+---------------------------------------------------------------------------------------------------------------------+
| CREATE TABLE default.test (                                                                                         |
|   a INT,                                                                                                            |
|   b INT                                                                                                             |
| )                                                                                                                   |
| WITH SERDEPROPERTIES ('serialization.format'='1')                                                                   |
| STORED AS TEXTFILE                                                                                                  |
| LOCATION 'hdfs://namenode-host:8020/user/hive/warehouse/test'                                 |
| TBLPROPERTIES ('numFiles'='3', 'COLUMN_STATS_ACCURATE'='true', 'numRows'='9', 'totalSize'='40', 'rawDataSize'='31') |
+---------------------------------------------------------------------------------------------------------------------+
Fetched 1 row(s) in 7.42s
[impala-host:21000] > alter table test change a a int comment 'test comment';
Query: alter table test change a a int comment 'test comment'

Fetched 0 row(s) in 0.66s
[impala-host:21000] > show create table test;
Query: show create table test
+---------------------------------------------------------------------------------------------------------------------+
| result                                                                                                              |
+---------------------------------------------------------------------------------------------------------------------+
| CREATE TABLE default.test (                                                                                         |
|   a INT COMMENT 'test comment',                                                                                     |
|   b INT                                                                                                             |
| )                                                                                                                   |
| WITH SERDEPROPERTIES ('serialization.format'='1')                                                                   |
| STORED AS TEXTFILE                                                                                                  |
| LOCATION 'hdfs://namenode-host:8020/user/hive/warehouse/test'                                 |
| TBLPROPERTIES ('numFiles'='3', 'COLUMN_STATS_ACCURATE'='true', 'numRows'='9', 'totalSize'='40', 'rawDataSize'='31') |
+---------------------------------------------------------------------------------------------------------------------+
Announcements