-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
samye760
committed
Mar 5, 2022
0 parents
commit 92f978e
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
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." |