Skip to content

Instantly share code, notes, and snippets.

@hakanilter
Last active July 20, 2018 10:32
Show Gist options
  • Save hakanilter/cfeca07d77c1c4c6b163f5498d434218 to your computer and use it in GitHub Desktop.
Save hakanilter/cfeca07d77c1c4c6b163f5498d434218 to your computer and use it in GitHub Desktop.
Script for generating CSV partitions report for Impala
# 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