--this will generate HiveException with message ASSERT_TRUE(): assertion failed
--it the table is empty and the script will exit
select assert_true(count(*)>0) from a;
--If previous statement executed successfully
create table b as
select * from table a;
select "Checking source is not empty ...";
select java_method("java.lang.System", "exit", 1) --Exit
from
(
select count(*) cnt
from a
)s where cnt=0; --select only if count=0
select "Creating the table b ...";
--Put create table here
1条答案
按热度按时间xdnvmnnf1#
可以有条件地使脚本失败
另一种方法是使用
java_method("java.lang.System", "exit", 1)
: