I want to change the column comments on an existing hive table using hive 0.13. This works:
create table test (mycolumn int); alter table test change mycolumn mycolumn int comment 'hello';
But I can't find a way to do this without repeating the name of the column and the type, both of which are irrelevant to the change. For example:
alter table test change mycolumn comment 'hello'; leads to an error.
If this was for one column it would not be a big deal but I want to do this for large numbers of columns in tables that were not commented. I know this could be done with a script that simply copies the column name and its type but would be nice to know if there were something simpler. Thanks
You can do this using ALTER command.
CREATE TABLE my_table
(id INT COMMENT 'id comment',
name STRING comment 'name comment');
-- change column comment as below.
ALTER TABLE my_table CHANGE id id INT COMMENT 'another comment';
-- see changed column
DESC EXTENDED my_table;
ALTER TABLE test_change CHANGE a1 a1 INT COMMENT 'this is column a1';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With