我在 2 个不同的模式中有同名的表。我想要做的是在格式的 2 个表中进行计数比较
表名:Count1:Count2
如何通过 Hive 查询实现这一点?
我在 2 个不同的模式中有同名的表。我想要做的是在格式的 2 个表中进行计数比较
表名:Count1:Count2
如何通过 Hive 查询实现这一点?
使用 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
您可以执行cross join
计数查询。
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;