我在hive表中有一个复杂的数据类型列,它是struct,内部struct我有十进制数据类型。我想将此结构(十进制(10,0))转换为struct(double)或struct(float),当我使用另一个表执行insert overwrite操作时。我可以实现这一点,因为当我尝试它给我一个错误 -
FAILED: SemanticException [Error 10044]: Line 1:23 Cannot insert into
target table because column number/types are different 'avro_poc_orc_test': Cannot convert column 3 from struct<latitude:decimal(28,2),longitude:decimal(19,3)> to struct<latitude:double,longitude:double>.
是否可以将复杂数据类型转换为另一种复杂数据类型?
答案 0 :(得分:2)
在构建相关字段时从其组件构造结构
with t as (select struct(cast (123 as decimal(10,0)),222,333,444) as s)
select struct(cast(t.s.col1 as double),t.s.col2,t.s.col3,t.s.col4)
from t
;