hive 全表全字段对比

 

 1 select
 2     *
 3 from (
 4     select 
 5          max(t1.source) as source
 6         ,t1.c1
 7         ,t1.c2 
 8         ,t1.c3
 9         ,count(*) as cnt
10     from (
11         select 1 as source, t11.* from dev.astron_wangluochayi_1 t11
12         union all
13         select 2 as source, t12.* from dev.astron_wangluochayi_1 t12
14     ) t1
15     group by t1.source,t1.c1,t1.c2 ,t1.c3
16     having count(*) = 1
17 ) t2
18 where t2.source = 1
19 ;

 

-- 此算法可能是最快的,但只能找出是否一致,如不一致,比较难找出差异
select
     flag
    ,count(1) as cnt
from (
    select
        concat_ws('|',ifnull(id,''),ifnull(name,'')) as flag
    from (
        select 1 as id, 'a' as name union all
        select 2 as id, 'b' as name union all
        select 3 as id, 'c' as name
    ) t1
    union all
    select 
        concat_ws('|',ifnull(id,''),ifnull(name,'')) as flag
    from (
        select 2 as id, 'b' as name union all
        select 3 as id, 'c' as name union all
        select 4 as id, 'd' as name
    ) t2
) t3
group by flag
having count(1) <> 2
;

 

-- full join

 

-- row_number 支持无主键表

 

未完待续

转载于:https://www.cnblogs.com/chenzechao/p/9444191.html

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值