Neethu Lalitha
Neethu Lalitha

Reputation: 3071

alter an existing map in hive

I have a hive table with one of the column as map data type .

map<int,struct<id :bigint,QTY:decimal(12,4),DISC_AMT:decimal(20,4),DISC_TYPE:string>>

Now I want to add one column inside the struct values like below:

map<int,struct<id :bigint,QTY:decimal(12,4),DISC_AMT:decimal(20,4),DISC_TYPE:string,new_column :int>>

Anyone know how to achieve this .

Thanks in advance.

Upvotes: 2

Views: 817

Answers (2)

David דודו Markovitz
David דודו Markovitz

Reputation: 44991

https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-ChangeColumnName/Type/Position/Comment

alter table t change column mycol mycol  map<int,struct<id:bigint,QTY:decimal(12,4),DISC_AMT:decimal(20,4),DISC_TYPE:string,new_column:int>>;

Notice that by default only new partitions will be impacted from the change.
If you want this to apply to all partitions add the word cascade at the end

Upvotes: 1

Neethu Lalitha
Neethu Lalitha

Reputation: 3071

Found the solution:

 alter table tablename change my_map_name my_map_name map<int,struct<id :bigint,QTY:decimal(12,4),DISC_AMT:decimal(20,4),DISC_TYPE:string,new_column :int>>;

Upvotes: 0

Related Questions