有条件的蜂巢掉落表

时间:2017-11-01 18:41:54

标签: bash hive hiveql oozie impala

我有两个表old_table和new_table。它们仅在行数方面有所不同。如果行数小于new_table,我会删除old_table。 我怎么能这个?

在hive中的hive还是shell脚本?

以下是我想要实现的目标: new =从new_table中选择count(); old = select count()来自old_table;

如果新的>旧的然后放下old_table;

1 个答案:

答案 0 :(得分:0)

是的,您可以使用bash脚本执行此操作,例如此类内容(未经测试):

new=$(hive -e 'select count(*) from new_table')
old=$(hive -e 'select count(*) from old_table')
echo "old : $old, new : $new"
if (( new > old )); then
  hive -e 'drop table old_table'
fi
相关问题