欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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)
相关标签: sql hash