- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
hdfs path for mulitple external hive table
- Labels:
-
Apache Hive
Created ‎05-01-2019 02:42 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
i have the below script to delete the hdfs path for all the tables from the database . i have retrieved all the tables from the database and write the tables list in the file .after that i am reading one by one and finding the path and deleting them .
Created ‎05-01-2019 11:49 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Did you try getting the path from metadata database. We can get the path of all hive tables with single query. Let me know if you already tried that.
-Shashi
Created ‎05-03-2019 04:21 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorry we don't have access for that .Can you please share that it will be useful for my future. Now i written different approach to get all hdfs paths and trying to delete them all in one shot .is there anyway to do that.
hive -e " set hive.cli.print.header=false; use $HIVE_SCHEMA;show tables like '*stg';" 1> $tablelist
tableNum_limit=$(cat $tablelist | wc -l)
echo "number of tables in the file $tableNum_limit "
#sed -i e"s/.*/SHOW CREATE TABLE $HIVE_SCHEMA.&;\" $tablelist
sed -i -e "s/.*/DESCRIBE FORMATTED $HIVE_SCHEMA.&;/" $tablelist
#create the file with all describe formatted output
hive -f $tablelist > $loctbl
#remove all the line except the hdfs path
sed -i -e '/^Location/!d;s/Location:\s\+//' $loctbl
#sed -Eni '{N; /^LOCATION\s+/p ; D}' $loctbl
It will retrieve all the hdfs paths into file for the given database and I am trying to delete them is there any short way to delete all in stead of using hdfs dfs -rm -r -skipTrash $table_location each path .
