Arrays 如何在配置单元中合并具有不同架构的表?

Arrays 如何在配置单元中合并具有不同架构的表?,arrays,hive,hiveql,union-all,Arrays,Hive,Hiveql,Union All,我在蜂箱中有两张桌子: 表A,其中包含类型为array的列N 表B,其中N列未出现 表A和B都包含C列 我想这样把他们结合起来: select g.* from (select N, C from A union all select null as N, C from B ) g; 但这会在配置单元中引发一个错误: FAILED:...Schema of both sides of union should match: Column N is of type array<stri

我在蜂箱中有两张桌子:

表A,其中包含类型为array的列N 表B,其中N列未出现 表A和B都包含C列

我想这样把他们结合起来:

select g.* from 

(select N, C from A
union all
select null as N, C from B
) g;
但这会在配置单元中引发一个错误:

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.
此操作失败,无法将基元类型规范中“数组”附近的输入识别为


我如何解决这个问题?谢谢。可能有一种更简单的方法,但我不确定如何在配置单元中表示空数组常量。您可以使用SQL进行以下操作:

select g.*
from (select N, C from A
      union all
      select A.N, C
      from B join
           A 
           on 1 = 0
     ) g;

换句话说,我可能不知道如何表达头顶上的常数。但是,我可以通过与一行不匹配来安排从A-获取它。

这会因为加入而变慢吗?@Candic3。老实说,我不知道。其他数据库在加入方面会非常聪明,但Hive可能不会。您总是可以从限制1中选择一个*之类的操作,这应该非常快。
select g.*
from (select N, C from A
      union all
      select A.N, C
      from B join
           A 
           on 1 = 0
     ) g;