shaofengshi closed pull request #344: #KYLIN-3684, HIVE_LIB is not set or not resolved correctly URL: https://github.com/apache/kylin/pull/344
This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/build/bin/find-hive-dependency.sh b/build/bin/find-hive-dependency.sh index a8793ebb3c..558c9b583c 100755 --- a/build/bin/find-hive-dependency.sh +++ b/build/bin/find-hive-dependency.sh @@ -37,6 +37,17 @@ else hive_env=`hive ${hive_conf_properties} -e set 2>&1 | grep 'env:CLASSPATH'` fi +if [ -z $hive_env ] +then + hive_permission=`hive ${hive_conf_properties} -e set 2>&1 | grep 'No valid credentials provided'` + if [ -n "$hive_permission" ] + then + quit "No valid credentials provided for Hive CLI, please check permission of hive. (e.g. check if Kerberos is expired or not)" + else + quit "Something wrong with Hive CLI or Beeline, please execute Hive CLI or Beeline CLI in terminal to find the root cause." + fi +fi + hive_classpath=`echo $hive_env | grep 'env:CLASSPATH' | awk -F '=' '{print $2}'` arr=(`echo $hive_classpath | cut -d ":" -f 1- | sed 's/:/ /g'`) hive_conf_path= @@ -73,6 +84,11 @@ then quit "Couldn't find hive configuration directory. Please set HIVE_CONF to the path which contains hive-site.xml." fi +if [ -z "$hive_exec_path" ] +then + quit "Couldn't find hive executable jar. Please check if hive executable jar exists in HIVE_LIB folder." +fi + # in some versions of hive hcatalog is not in hive's classpath, find it separately if [ -z "$HCAT_HOME" ] then @@ -89,7 +105,7 @@ then elif [ -n is_aws ] && [ -d "/usr/lib/hive-hcatalog" ]; then # special handling for Amazon EMR hcatalog_home=/usr/lib/hive-hcatalog - else + else quit "Couldn't locate hcatalog installation, please make sure it is installed and set HCAT_HOME to the path." fi else @@ -106,7 +122,27 @@ fi function checkFileExist() { - files=(`echo $1 | cut -d ":" -f 1- | sed 's/:/ /g'`) + msg_hint="" + if [ "$1" == "hive_lib" ] + then + msg_hint=", please check jar files in current HIVE_LIB or export HIVE_LIB='YOUR_LOCAL_HIVE_LIB'" + elif [ "$1" == "hcatalog" ] + then + msg_hint=", please check jar files in current HCAT_HOME or export HCAT_HOME='YOUR_LOCAL_HCAT_HOME'" + fi + + if [ -z "$2" ] + then + if [ "$1" == "hive_lib" ] + then + quit "Current HIVE_LIB is not valid, please export HIVE_LIB='YOUR_LOCAL_HIVE_LIB'" + elif [ "$1" == "hcatalog" ] + then + quit "Current HCAT_HOME is not valid, please export HCAT_HOME='YOUR_LOCAL_HCAT_HOME'" + fi + fi + + files=(`echo $2 | cut -d ":" -f 1- | sed 's/:/ /g'`) misFiles=0 outputMissFiles= for file in ${files} @@ -119,7 +155,7 @@ function checkFileExist() done if [ 0 != ${misFiles} ]; then times=`expr ${allFiles} / ${misFiles}` - [[ ${times} -gt 10 ]] || quit "A couple of hive jars can't be found: ${outputMisFiles}, please export HIVE_LIB='YOUR_LOCAL_HIVE_LIB'" + [[ ${times} -gt 10 ]] || quit "A couple of hive jars can't be found: ${outputMisFiles}${msg_hint}" fi } @@ -146,15 +182,20 @@ function validateDirectory() if [ -z "$HIVE_LIB" ] then verbose "HIVE_LIB is not set, try to retrieve hive lib from hive_exec_path" - hive_lib_dir="$(dirname $hive_exec_path)" + if [[ $hive_exec_path =~ ^\/.*hive.*\/lib\/hive-exec[a-z0-9A-Z\.-]*.jar ]] + then + hive_lib_dir="$(dirname $hive_exec_path)" + else + quit "HIVE_LIB not found, please check hive installation or export HIVE_LIB='YOUR_LOCAL_HIVE_LIB'." + fi else hive_lib_dir="$HIVE_LIB" fi hive_lib=`find -L ${hive_lib_dir} -name '*.jar' ! -name '*druid*' ! -name '*slf4j*' ! -name '*avatica*' ! -name '*calcite*' ! -name '*jackson-datatype-joda*' ! -name '*derby*' -printf '%p:' | sed 's/:$//'` validateDirectory ${hive_conf_path} -checkFileExist ${hive_lib} -checkFileExist ${hcatalog} +checkFileExist hive_lib ${hive_lib} +checkFileExist hcatalog ${hcatalog} hive_dependency=${hive_conf_path}:${hive_lib}:${hcatalog} verbose "hive dependency is $hive_dependency" ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services