1. 程式人生 > >impala重新整理hive資料shell指令碼

impala重新整理hive資料shell指令碼

#!/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