我有一个简单的表格fiction_movie
:
hive>describe fiction_movie;
OK
title string
actors array<string>
genre string
rating int
4 rows selected (0.03 seconds)
表中的内容:
hive> select * from fiction_movie;
OK
avatar ["zoe saldana","Sam worthington"] science fiction 7
logan ["hugh jackman","Patrick stewart"] science fiction 8
2 rows selected (0.352 seconds)
我想做的是重新排列列位置并将标题放在流派之后:
#I tried
hive>alter table fiction_movie change column title title string after genre;
但它给了我以下错误:
错误:处理语句时出错:失败:执行错误,从 org.apache.hadoop.hive.ql.exec.DDLTask 返回代码 1。无法更改表。以下列的类型与各自位置的现有列不兼容:
演员,流派(状态=08S01,代码=1(
有谁知道为什么?谢谢!
这段代码在我的机器中完美运行。
hive> create table fiction_movie(
> title string,
> actors array<string>,
> genre string,
> rating int);
OK
Time taken: 0.155 seconds
hive> alter table fiction_movie change column title title string after genre;
OK
Time taken: 0.4 seconds
hive> describe fiction_movie;
OK
actors array<string>
genre string
title string
rating int
Time taken: 0.37 seconds, Fetched: 4 row(s)
或者尝试设置此属性。 可以强制 hive 允许您使用以下方法进行更改:
`SET hive.metastore.disallow.invalid.col.type.changes=true;`
而不是改变你的桌子。