错误码:ODPS-0130241: Illegal union operation
错误1:Illegal union operation - type mismatch for column xx of UNION, left is YY while right is ZZ
错误信息示例
ODPS-0130241:[m,n] Illegal union operation - type mismatch for column xx of UNION, left is YY while right is ZZ
问题描述
两个表进行union操作的时候,要求这两个表的数据类型必须匹配,否则会报错。
解决方案
修改query,必要时可以执行显式类型转换,以保证union两边数据的类型相匹配。
Query示例
--创建表
odps> create table mc_test1
(
a string
);
odps> create table mc_test2
(
a bigint
);
--错误,union两边的数据类型不匹配
odps> (select a
from mc_test1)
union all
(select a
from mc_test2);
FAILED: ODPS-0130241:[4,9] Illegal union operation - type mismatch for column 0 of UNION, left is STRING while right is BIGINT
--正确,使用显式类型转换以保证union两边的数据类型一致:
odps> (select a
from mc_test1)
union all
(select cast(a as string)
from mc_test2);
文档内容是否对您有帮助?