Reputation: 4197
I need to run an HQL file and do things based on the result. The HQL file creates a table. Below is how I'm calling the script from my bash script.
if echo -e "hive -f $table_create_file -hiveconf database='$hive_db' -hiveconf table='$hive_table_name' -hiveconf query='$hive_query'"
then
echo "success"
else
echo "error message"
exit 100
fi
But this returns success even if the create table command inside the HQL file fails. I believe this is because I am not piping to the hive terminal. How can I handle this situation? Any help would be much appreciated.
Upvotes: 1
Views: 4295
Reputation: 85560
If the hive
command returns success/fail return code depending upon the status of the execution, you can directly use it in the if-clause
as
if hive -hiveconf database="$hive_db" -hiveconf table="$hive_table_name" -hiveconf query="$hive_query" -f "$table_create_file"
then
echo "success"
else
echo "error message"
exit 100
fi
I have double-quoted all the variables for the shell
to expand it on execution.
Upvotes: 1