Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
samye760 committed Mar 5, 2022
0 parents commit 92f978e
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions HiveDDLs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash

tables=$1
ddl_name='/home/d88665/HiveTableDDL.txt'
combined_ddl='/home/d88665/HiveDDLs.txt'

wc $tables

wait

cat $tables | while read LINE
do
sleep .5
echo $LINE
sleep .5
hive -e "show create table $LINE" > temp.txt
sleep .5
sed -i '/TBLPROPERTIES/,$d' temp.txt
sleep .5
sed -i '$ s/$/;/' temp.txt
sleep .5
cat temp.txt >> DDLs.hql
sleep .5
echo -e "\n" >> DDLs.hql
sleep .5
echo $LINE
sleep .5
done

sleep .5

sed -i 's/CREATE EXTERNAL TABLE/CREATE EXTERNAL TABLE IF NOT EXISTS/g' DDLs.hql

sleep .5

sed -i 's/edl-test1//g' DDLs.hql

sleep .5

sed -ir 's/2022.*//g' DDLs.hql

WC=$(grep "CREATE EXTERNAL TABLE" DDLs.hql | wc -l)

sleep .5

echo "Table DDL generated for ${WC} tables."

0 comments on commit 92f978e

Please sign in to comment.