Last active
July 20, 2018 10:32
-
-
Save hakanilter/cfeca07d77c1c4c6b163f5498d434218 to your computer and use it in GitHub Desktop.
Script for generating CSV partitions report for Impala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Script for generating csv partitions report for Impala | |
IMPALA_DAEMON=localhost | |
databases=$(impala-shell --quiet -i $IMPALA_DAEMON -d default --delimited -q "SHOW DATABASES" | cut -f1 | grep -e dl -e ods_) | |
for database in $databases | |
do | |
echo $database | |
directory="partitions/$database" | |
mkdir -p $directory | |
tables=$(impala-shell --quiet -i $IMPALA_DAEMON -d $database --delimited -q "SHOW TABLES") | |
for table in $tables | |
do | |
echo $table | |
impala-shell -i $IMPALA_DAEMON -d $database -q "SHOW PARTITIONS \`$table\`" --delimited --print_header > "$directory/$table.csv" | |
find $directory -size 0 -delete | |
done | |
done | |
find partitions/ -type d -empty -delete | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment