hive放置表的条件

dy1byipe  于 2021-06-26  发布在  Hive
关注(0)|答案(1)|浏览(297)

我有两张table旧table和新table。它们只是行数不同。如果行计数小于新表,我将删除旧表。我怎么能把这个放进Hive?
在Hive里还是在oozie里作为一个shell脚本?
下面是我试图实现的东西:new=select count()from new\u table;old=从旧表中选择count();
如果new>old,则删除旧表;

wfauudbj

wfauudbj1#

是的,您可以使用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

相关问题