Member since
04-18-2016
2
Posts
0
Kudos Received
0
Solutions
05-08-2016
08:15 PM
Not only do we restrict access to hive in our environment but we also make people use a command called 'hql' which is a wrapper around beeline. By default a user (on our kerberised cluster and therefore they have already done kinit) can just type 'hql' and be in the defaults or pass simple options to specify non-defaults #!/bin/bash
# David M Walker, Data Management & Warehousing & Worldpay
# hql command line for use with a Kerborised cluster
DATABASE="DEFAULT"
QUERY_FILE=""
HOST="localhost"
PORT="10001"
QUEUE="DEFAULT"
REALM="_HOST@REALM"
while getopts :d:h:p:r:q:f: PARAM
do
case "${PARAM}" in
d) DATABASE="${OPTARG}"
;;
f) QUERY_FILE="${OPTARG}"
;;
h) HOST="${OPTARG}"
;;
p) PORT="${OPTARG}"
;;
q) QUEUE="${OPTARG}"
;;
r) REALM="${OPTARG}"
;;
?) echo "Usage: hql [-d DATABASE] [-h HOST] [-p PORT] [-q QUEUE] [-r REALM] [-f QUERY_FILE]"
exit 1
;;
esac
done
shift $(($OPTIND - 1))
if [ -z "${QUERY_FILE}" ]
then
beeline -u "jdbc:hive2://${HOST}:${PORT}/${DATABASE};transportMode=http;httpPath=cliservice;principal=hive/${REALM}" --hiveconf tez.queue.name=${QUEUE}
exit $?
else
if [ -r "${QUERY_FILE}" ]
then
beeline -u "jdbc:hive2://${HOST}:${PORT}/${DATABASE};transportMode=http;httpPath=cliservice;principal=hive/${REALM}" --hiveconf tez.queue.name=${QUEUE} -f ${QUERY_FILE}
exit $?
else
echo "File ${QUERY_FILE} is not readable"
exit 1
fi
fi
exit 0
... View more