Update new added columns in hive

334 views Asked by At

I have been trying to make updates to an orc table in hive which is bucketed and also set transactional=true property. The normal update works great but as soon as I alter the table and add a new column e.g. column_added_5, and try to update column_added_5 the statement executes but the column does not get updated.

Any help/directions is appreciated.

2

There are 2 answers

0
AudioBubble On

Did you try this:

ALTER TABLE table_name ADD COLUMNS ( column_added_5 STRING COMMENT 'Column 5');
0
Francisco Lopez On

I think that one way is:

CREATE TABLE new_table_name AS SELECT column1,column2,column3, ... "default_value" as column_added_5 FROM your_table_name;

DROP TABLE your_table_name;

ALTER TABLE new_table_name RENAME TO your_table_name;