impala重新整理hive資料shell指令碼
阿新 • • 發佈:2018-12-22
#!/bin/bash
source job.properties
impalaHost=$1
databaseName=$2
tableName=$3
echo "[INFO]: Hive Database :------> ${databaseName}"
echo "[INFO]: Table Name :---------> ${tableName}"
echo "[INFO]: Impala Host :--------> ${impalaHost}"
echo " "
export PYTHON_EGG_CACHE=./myeggs
#Impala metadata refresh
impala-shell -i ${impalaHost} -d ${databaseName} -q "invalidate metadata ${tableName}";
#Check if the above command executed successfully.
if [ $? -eq 0 ]; then
echo "[INFO]: The impala invalidate metadata command executed successfully."
else
echo "[ERROR]: Problem in executing the Impala invalidate metadata command."
exit 1
fi
#Refresh the impala tableName
impala-shell -i ${impalaHost} -d ${databaseName} -q "REFRESH ${tableName}";
#Check if the above command executed successfully.
if [ $? -eq 0 ]; then
echo "[INFO]: The impala REFRESH ${tableName} command executed successfully."
else
echo "[ERROR]: Problem in executing the Impala REFRESH ${tableName} command."
exit 1
fi
echo " "
echo "[INFO]: The impala table and metadata refreshed successfully."
exit 0
source job.properties
impalaHost=$1
databaseName=$2
tableName=$3
echo "[INFO]: Hive Database :------> ${databaseName}"
echo "[INFO]: Table Name :---------> ${tableName}"
echo "[INFO]: Impala Host :--------> ${impalaHost}"
echo " "
export PYTHON_EGG_CACHE=./myeggs
#Impala metadata refresh
impala-shell -i ${impalaHost} -d ${databaseName} -q "invalidate metadata ${tableName}";
#Check if the above command executed successfully.
if [ $? -eq 0 ]; then
echo "[INFO]: The impala invalidate metadata command executed successfully."
else
echo "[ERROR]: Problem in executing the Impala invalidate metadata command."
exit 1
fi
#Refresh the impala tableName
impala-shell -i ${impalaHost} -d ${databaseName} -q "REFRESH ${tableName}";
#Check if the above command executed successfully.
if [ $? -eq 0 ]; then
echo "[INFO]: The impala REFRESH ${tableName} command executed successfully."
else
echo "[ERROR]: Problem in executing the Impala REFRESH ${tableName} command."
exit 1
fi
echo " "
echo "[INFO]: The impala table and metadata refreshed successfully."
exit 0