更改配置单元多列 [英] alter hive multiple column

查看:161
本文介绍了更改配置单元多列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们如何修改Hive中多列的数据类型?

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);


推荐答案

据我所知,你不能。在蜂巢文档可以发现以下:

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列名] [CASCADE | RESTRICT];

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];

此命令将允许用户改变列的名称,数据类型,注释,或位置,或者它们的任意组合。 PARTITION子句在Hive 0.14.0及更高版本中可用;请参阅升级Pre-Hive 0.13.0十进制列以了解使用情况。 Hive 0.13的补丁也可以使用(见HIVE-7971)。

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.

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

这篇关于更改配置单元多列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆