impala查询数据与hive的查询数据比对
先在cdh的hue中分别用impala和hive的查询数据对比
将impala的查询语句写入到shell脚本中
a=(`impala-shell -q 'SELECT count(1) FROM educator.t_event WHERE event_name = "startApp" AND date_time ="2021-06-07" ' )
hive的sql语句写入shell中
b=(`hive -e 'SELECT count(1) FROM educator.t_event WHERE event_name = "startApp" AND date_time ="2021-06-07"' `)
echo $b
在进行if循环对比
if [ "$a" = "$b" ]; then
echo "==========startApp ok============="
else
echo "==========startApp abnormal======="
fi
这是什么鬼
后来发现原来impala的查询出来的格式不一样的
解决问题
后来在impala的语句后面加上-B格式化,就可以与hive的查询数据保持一样了
最后的脚本
#! /bin/bash
a=(`impala-shell -q 'SELECT count(1) FROM educator.t_event WHERE event_name = "startApp" AND date_time ="2021-06-07" ' -B`)
echo $a
b=(`hive -e 'SELECT count(1) FROM educator.t_event WHERE event_name = "startApp" AND date_time ="2021-06-07"' `)
echo $b
if [ "$a" = "$b" ]; then
echo "==========startApp ok============="
else
echo "==========startApp abnormal======="
fi
OK了
|