I am trying to do count comparision between two table . As minus operator does not work in hive , it is not happening. Could you please give some simple way to do count comparision between two tables.
select 'Call Detail - Hive T1 to HDFS Staging - Data Compare',
case when cnt>0 then 'Fail' Else 'Pass' end
from
(select count(*) cnt from (
(select
count(*) from students1 s1)-
(select count(*) from students2 s2)
) as tbl1
) as tbl2;
It's throwing error:
FAILED: ParseException line 81:0 cannot recognize input near '(' '(' 'select' in from source
check out below query .. it's working fine locally at my system. Let me know if it helps.
Use
cross join
if you have no group by columns. In this case it will produce one row with both counts:If you will add some group by columns to compare on more detailed grain, then use
FULL JOIN
on group by columns:This query will return joined rows with difference calculated and also not joined rows from both tables.