Hive 如果记录不是0,如何将查询结果分配给查询中的单个变量并返回错误

Hive 如果记录不是0,如何将查询结果分配给查询中的单个变量并返回错误,hive,hiveql,hue,Hive,Hiveql,Hue,如果存在记录,如何将查询结果count*值分配给单个变量并返回错误 按productid、第1列、第2列和第3列在分区上选择*fromselect count* 按productid描述的订单作为重复计数 来自表1选项卡 其中重复计数>1 您可以使用shell: dups=$(hive -S -e "select nvl(count(*),0) from(select count(*) over (partition By productid, column1,column2,colu

如果存在记录,如何将查询结果count*值分配给单个变量并返回错误

按productid、第1列、第2列和第3列在分区上选择*fromselect count* 按productid描述的订单作为重复计数 来自表1选项卡 其中重复计数>1

您可以使用shell:

dups=$(hive -S -e "select nvl(count(*),0) from(select count(*) over (partition By productid, column1,column2,column3) as duplicate_count from table1)tab where duplicate_count> 1")
if [ "$dups" != "0" ]; then
    echo "Failed, duplicates found: $dups"
    #Do something here, log or send messege, etc
    exit 1
fi
仅在配置单元中,如果没有shell,则不能对同一个变量使用变量,但可以使用assert\u true生成异常

您可以使用shell:

dups=$(hive -S -e "select nvl(count(*),0) from(select count(*) over (partition By productid, column1,column2,column3) as duplicate_count from table1)tab where duplicate_count> 1")
if [ "$dups" != "0" ]; then
    echo "Failed, duplicates found: $dups"
    #Do something here, log or send messege, etc
    exit 1
fi
仅在配置单元中,如果没有shell,则不能对同一个变量使用变量,但可以使用assert\u true生成异常