Reputation: 1092
I have multiple Databases
in Hive
. A, B, C
.
Database A has hive tables One, Two, Three.
All three tables have different schemas
.
How can I write a hive script to dump data of all three tables into a single csv file.
Upvotes: 0
Views: 787
Reputation: 1058
Try this.
#!/bin/bash
for db in A B C #List of databases
do
tbs=$(hive -S -e "use $db; show tables")
for tb in $tbs
do
hive -e "set hive.cli.print.header=true; use $db; SELECT * FROM $tb;" | sed 's/[\t]/,/g' >> sampleData.csv
done
done
Upvotes: 1