From be9726bc523e3a3db9ef89ae8b01fd40faafdcf9 Mon Sep 17 00:00:00 2001 From: Peter Slawski Date: Tue, 14 Jun 2016 19:56:40 -0700 Subject: [PATCH] HIVE-14288: Suppress 'which: no hbase' error message outputted from hive cli This suppresses an error message always outputted from the hive cli when HBase is not installed. This was introduced in HIVE-12058 which had the intention of removing suppression of such error messages for hbase related logic as it made it harder to debug. However, if HBase is not being used, then always printing the same error message does not make sense. To compromise, the --verbose parameter was added to the hive cli to allow more information to be printed out for debugging purposes. In particular, with this flag set, a friendlier message is printed regarding not being able to find the hbase bin script. --- bin/ext/help.sh | 1 + bin/hive | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/bin/ext/help.sh b/bin/ext/help.sh index 2bb5d13..45cec6f 100644 --- a/bin/ext/help.sh +++ b/bin/ext/help.sh @@ -23,6 +23,7 @@ help() { echo " --auxpath : Auxillary jars " echo " --config : Hive configuration directory" echo " --service : Starts specific service/component. cli is default" + echo " --verbose : Prints additional information useful for debugging" echo "Parameters used:" echo " HADOOP_HOME or HADOOP_PREFIX : Hadoop install directory" echo " HIVE_OPT : Hive options" diff --git a/bin/hive b/bin/hive index 3b9f3e0..8535735 100755 --- a/bin/hive +++ b/bin/hive @@ -28,6 +28,7 @@ bin=`cd "$bin"; pwd` TMP_USER_DIR="/tmp/${USER}" STDERR="${TMP_USER_DIR}/stderr" SERVICE="" +VERBOSE="" HELP="" while [ $# -gt 0 ]; do case "$1" in @@ -52,6 +53,10 @@ while [ $# -gt 0 ]; do SERVICE=llapdump shift ;; + --verbose) + VERBOSE=_verbose + shift + ;; --help) HELP=_help shift @@ -260,7 +265,11 @@ fi if [[ -e $HBASE_HOME/bin/hbase ]] ; then HBASE_BIN="$HBASE_HOME/bin/hbase" fi -HBASE_BIN=${HBASE_BIN:-"$(which hbase)"} +HBASE_BIN=${HBASE_BIN:-"$(which hbase 2>/dev/null)"} + +if [[ -z $HBASE_BIN ]] && [[ -n $VERBOSE ]] ; then + echo "Cannot find hbase bin: For HBase integration, please set \$HBASE_BIN or add hbase to the path" +fi # perhaps we've located HBase. If so, include its details on the classpath if [[ -n $HBASE_BIN ]] ; then -- 2.5.4 (Apple Git-61)