我在 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做到这一点?我知道我可以使用创建表并复制数据来做到这一点,但是我想知道是否还有另一种方法可以做到这一点。
更新
我正在使用配置单元:2.1.0.2.6.1.0-129
HortonWorks:HDP-2.6.1.0
最佳答案
这是您需要提供的命令,
ALTER TABLE dirceu CHANGE COLUMN a a STRUCT<b:STRING, c:STRING, d:STRING>;
您不能向“集合”数据类型添加新字段。相反,您需要完全更改架构。
希望你喜欢答案。呀!
关于hadoop - 我可以使用alter table将子列添加到配置单元结构列吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47293653/