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

原文:https://blog.csdn.net/lijixianglijixiang/article/details/72722335 

你可能感兴趣的:(hive,etl)