You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hive.apache.org by Daniel Haviv <da...@veracity-group.com> on 2014/12/02 19:16:09 UTC

Running hive inside a bash script

Hi,
I have a bash script that runs a hive query and I would like it to do
something if the query succeeds and something else if it fails.
My testings show that a query failure does not change Hive's exit code,
what's the right way to achieve this ?

Thanks,
Daniel

Re: Running hive inside a bash script

Posted by John Omernik <jo...@omernik.com>.
That's not what I've found:

$ hive -e "show tables"
table1
table2

$ echo $?
0

$ hive -e "show partitions notable"
FAILED: SemanticException [Error 10001]: Table not found notable

$ echo $?
17


In a bash script:

hive -e "show partitions notable"
hiveresult=`echo $?`
if [ $hiveresult -ne 0 ]; then
    echo "We have a hive Error!!!!"
    echo "Hive Error Num $hiveresult"
    exit 1

else

   echo "Great, no Hive errror, Moving on"

fi



On Tue, Dec 2, 2014 at 12:16 PM, Daniel Haviv
<da...@veracity-group.com> wrote:
> Hi,
> I have a bash script that runs a hive query and I would like it to do
> something if the query succeeds and something else if it fails.
> My testings show that a query failure does not change Hive's exit code,
> what's the right way to achieve this ?
>
> Thanks,
> Daniel