alter hive multiple column

懵懂的女人 提交于 2019-12-07 14:26:13

问题


How do we alter the datatype of multiple columns in Hive ?

CREATE TABLE test_change (a int, b int, c int);

ALTER TABLE test_change CHANGE a a string b b doube c c decimal(11,2);

回答1:


As far as I know, you can't. In the Hive documentation you can find the following:

ALTER TABLE table_name [PARTITION partition_spec] CHANGE [COLUMN] col_old_name col_new_name column_type [COMMENT col_comment] [FIRST|AFTER column_name] [CASCADE|RESTRICT];

This command will allow users to change a column's name, data type, comment, or position, or an arbitrary combination of them. The PARTITION clause is available in Hive 0.14.0 and later; see Upgrading Pre-Hive 0.13.0 Decimal Columns for usage. A patch for Hive 0.13 is also available (see HIVE-7971).

The documentation is speaking about "a column". The alternative would be to write multiple queries, one for each datatype you have to change.

Reference: https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL



来源:https://stackoverflow.com/questions/41613590/alter-hive-multiple-column

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!