Hive: Repair Full Database

Hive provides a command to repair individual tables but lacks a command to repair full database at once

Following script can be used to repair full database

#!/bin/bash
if [ $# -lt 1 ]
    then
        echo "Error: Please supply database name to be repaired!"
        exit 1
fi

DB=$1
TABLES="tables.hql"
echo "--" > $TABLES
for TABLE in `hive --database $DB -S -e 'show tables;'`
do
    echo "msck repair table $TABLE;" >> $TABLES
done
echo "Repairing tables..."
cat $TABLES
hive --database $DB -f $TABLES
echo "Done!"
Latest

1 comments:

It is very well written, we have also written it on our website Editingokay