Support Questions

Find answers, ask questions, and share your expertise

Issue Loading Data from HIVE Table into CSV File in HDFS

avatar

I am trying to run this query to load data from Hive Table to HDFS file. IT executes successfully but does not show any CSV file in the directory(sTestData) in hdfs. Any suggestions on what may be wrong with query or the access to the hdfs directory ?

INSERT OVERWRITE LOCAL DIRECTORY '/STestData/customershare.csv' ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' SELECT * FROM stestdata.customershare

1 ACCEPTED SOLUTION

avatar
Super Guru

The LOCAL keyword tells Hive to write the data to the local filesystem, not HDFS.

View solution in original post

4 REPLIES 4

avatar
Super Guru

The LOCAL keyword tells Hive to write the data to the local filesystem, not HDFS.

avatar

Thanks Michael. I removed local keyword and it works fine now. Is there a specific location in local where it creates this in subdirectory by default ?

avatar
Super Guru

You are welcome. Don't forget to accept the answer. 🙂

It should use the full pathname you specify after the DIRECTORY keyword. A common testing approach would be to use the tmp directory like '/tmp/my-output.cvv' and see if it is working as expected.

avatar

Insert Overwrite is creating a CSV file as directory name and with a file named 000000_0 with all the content. How can I make this to create CSV file with exact name that I give like customershare.csv from above query ?