Hive 从配置单元中的多个表中选择计数(*)

Hive 从配置单元中的多个表中选择计数(*),hive,hiveql,amazon-emr,hive-query,Hive,Hiveql,Amazon Emr,Hive Query,我在两个不同的模式中有相同名称的表。我要做的是在格式中的两个表中进行计数比较 表名:Count1:Count2 如何通过配置单元查询实现这一点?使用UNION ALL: select 'db1.table_name' table_name, count(col1) count1, count(col2) count2 from db1.table_name UNION ALL select 'db2.table_name' table_name, count(col1) count1, coun

我在两个不同的模式中有相同名称的表。我要做的是在格式中的两个表中进行计数比较

表名:Count1:Count2

如何通过配置单元查询实现这一点?

使用UNION ALL:

select 'db1.table_name' table_name, count(col1) count1, count(col2) count2 from db1.table_name
UNION ALL
select 'db2.table_name' table_name, count(col1) count1, count(col2) count2 from db2.table_name

您可以执行计数查询的交叉联接

select t1.count1,t2.count2
from (select count(*) as count1 from tbl1) t1
cross join (select count(*) as count2 from tbl2) t2
尝试完全外部连接

select tt1.cn,tt2.cn from 
    (select count(1) as cn from db1.table) tt1 
full outer join 
    (select count(1) as cn from db2.table ) tt2
on tt1.cn=tt2.cn; 

您好,我能够获得所需格式的结果,但我必须将hive.strict.checks.cartesian.product设置为false。默认情况下,它被设置为true。这张支票是什么?我把它设为真,是否有任何风险?