我可以使用alter table将子列添加到hive struct列吗?

时间:2017-11-14 19:19:22

标签: hadoop hive

我在hive中有一个非常复杂的表结构,让我们说它就像下表:

create table dirceu ( a struct<b:string,c:string>);

现在我需要在a列中添加另一个子列,它应该具有结构b,c和d,我正在尝试使用以下alter table:

alter table dirceu change column a a struct<b:string,c:string, d:string>;

但是这会引发以下错误:

Error: Error while processing statement: FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. Unable to alter table. The following columns have types incompatible with the existing columns in their respective positions :
a (state=08S01,code=1)

有没有办法使用alter table来做到这一点?我知道我可以使用create table并复制数据,但我想知道是否有其他方法可以做到这一点。  的更新 我正在使用配置单元:2.1.0.2.6.1.0-129 HortonWorks:HDP-2.6.1.0

2 个答案:

答案 0 :(得分:0)

这是您需要提供的命令,

ALTER TABLE dirceu CHANGE COLUMN a a STRUCT<b:STRING, c:STRING, d:STRING>;

您无法向Collection数据类型添加新字段。相反,您需要完全更改架构。 希望你喜欢这个答案。 YIPPEE !!

答案 1 :(得分:-1)

我想它可以通过这个命令工作,

alter table dirceu add column a struct<d:string>;

如果评论不起作用,请告诉我。