2021-02-18 16:23:34 +01:00
|
|
|
export PYTHON_EGG_CACHE=/home/$(whoami)/.python-eggs
|
|
|
|
export link_folder=/tmp/impala-shell-python-egg-cache-$(whoami)
|
|
|
|
if ! [ -L $link_folder ]
|
|
|
|
then
|
|
|
|
rm -Rf "$link_folder"
|
|
|
|
ln -sfn ${PYTHON_EGG_CACHE}${link_folder} ${link_folder}
|
|
|
|
fi
|
|
|
|
|
|
|
|
export SOURCE=$1
|
|
|
|
export SHADOW=$2
|
|
|
|
|
|
|
|
echo "Updating shadow database"
|
2021-04-15 15:03:05 +02:00
|
|
|
impala-shell -q "invalidate metadata"
|
2021-02-19 02:18:47 +01:00
|
|
|
impala-shell -d ${SOURCE} -q "invalidate metadata"
|
2021-02-19 01:54:39 +01:00
|
|
|
impala-shell -d ${SOURCE} -q "show tables" --delimited | sed "s/^\(.*\)/compute stats ${SOURCE}.\1;/" | impala-shell -c -f -
|
2021-02-18 16:23:34 +01:00
|
|
|
impala-shell -q "create database if not exists ${SHADOW}"
|
2021-02-19 02:18:47 +01:00
|
|
|
impala-shell -d ${SHADOW} -q "show tables" --delimited | sed "s/^/drop view if exists ${SHADOW}./" | sed "s/$/;/" | impala-shell -c -f -
|
|
|
|
impala-shell -d ${SOURCE} -q "show tables" --delimited | sed "s/\(.*\)/create view ${SHADOW}.\1 as select * from ${SOURCE}.\1;/" | impala-shell -c -f -
|
2021-02-18 16:23:34 +01:00
|
|
|
echo "Shadow db ready!"
|