Coder123
Coder123

Reputation: 344

How to export table schema into a csv file

Basically, I want to export a hive table's schema into a csv file. I can create a datframe and then show its schema but I want to write its schema to a csv file. Seems pretty simple but it wont work.

Upvotes: 0

Views: 709

Answers (1)

Sagar Morakhia
Sagar Morakhia

Reputation: 797

Incase you wanna do it within Hive console. This is how you do it

hive>
INSERT OVERWRITE LOCAL DIRECTORY '/tmp/user1/file1'
ROW FORMAT DELIMITED FIELDS TERMINATED BY ','
SELECT * from tablename

And then in Unix

[user1]$
cat file1/* > file1.csv
zip file1 file1.csv

Upvotes: 1

Related Questions