hive数仓、数据中台数据核对的方法
程序员文章站
2022-03-03 20:42:19
...
采用hash函数
with a as(
select 1 as c1
,null as c2
,3 as id
union all
select 1 as c1
,0 as c2
,3 as id
)
,
with b as (
select 1 as c1
,null as c2
union all
select 1 as c1
,0 as c2
)
select a.c1
,b.c1
a.c2
b.c2
from a
left join b
on a.id =b.id
where hash(a.c1+1 --加1的目的是因为hash(0)=hash(null),这两个意义不一样
,b.c2+1
)
<>
hash(b.c1+1
,b.c2+1)