我昨天刚开始学习 hive,我一直致力于更改 hive 中列的类型。我想问列类型的更改是否对它们有某种限制,因为我只能进行特定类型的更改,例如我可以将 int 转换为 double、string 转换为 double、double 转换为 string 但我无法将 string 更改为 int、double至 int。
ALTER TABLE student CHANGE rollno rollno int;
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 :
rollno
hive> DESCRIBE FORMATTED student
> ;
OK
# col_name data_type comment
rollno int
name string
phno string
city string
ALTER TABLE student CHANGE rollno rollno double;
OK
Time taken: 0.144 seconds
ALTER TABLE student CHANGE rollno rollno int;
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 :
rollno
也不能用字符串来做。所以请引导我找到答案,因为我似乎无法通过谷歌找到任何东西。
如果你只想改变列类型,不关心隐式转换
例如,旧的列类型是错误的。
你可以试试这个:
set hive.metastore.disallow.incompatible.col.type.changes=false;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)