我在HIVE中有两张表:
表A和B都包含列" C"。
我想像这样结合他们:
select g.* from
(select N, C from A
union all
select null as N, C from B
) g;
但这会引发HIVE错误:
FAILED:...Schema of both sides of union should match: Column N is of type array<string> on first table and type void on second table.
所以,我尝试转换数据类型:
select g.* from
(select N, C from A
union all
select cast(null as array) as N, C from B
) g;
此操作因"cannot recognize input near 'array' ')' 'as' in primitive type specification.
我该如何解决这个问题?感谢
答案 0 :(得分:0)
嗯。可能有一种更简单的方法,但我不确定如何在Hive中表达NULL
数组常量。您可以使用SQL:
select g.*
from (select N, C from A
union all
select A.N, C
from B join
A
on 1 = 0
) g;
换句话说,我可能不知道如何表达这个常数。但是,我可以安排从A
获取 - 无法匹配到一行。