Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]
Created 01-06-2016 07:01 PM
Can anyone let me know how to use Sqoop to export data from Hive to a flat file to be picked up by Hive again?
I understand that Sqoop can export data to tables, however I have a scenario where I want to export data into flat files
Created 01-07-2016 12:53 AM
Thanks Artem and Neeraj. I just copied the data from /apps/hive/warehouse to a local directory.
Note: Hive data is not necessary located in the folder mentioned above. i.e. external table can be defined anywhere within the HDFS. hive –e “DESCRIBE FORMATTED <tablename>” > <tablename_descformat>.txt;
This command is to collect detail information of tables. The detail information for a table includes column, partition, database it belongs, owner, create time, last access time, protect mode, location, table type, storage information and etc.
Created 01-06-2016 08:15 PM
unless you're using orc, the files you use for Hive are in their raw form. You can just browse to /apps/hive/warehouse dir and look at them. No need to use sqoop.
Created 01-06-2016 11:02 PM
Thanks for reply. I'm using orc format
Created 01-10-2016 12:44 PM
@vijaya inturi you can also read orc and output to flat file using pig
A = load ‘student.orc’ using OrcStorage();
Store A into 'file' using PigStorage([options]);
Created 01-06-2016 09:53 PM
You can use this to write into HDFS from existing table
INSERT OVERWRITE DIRECTORY '/path/to/output/dir' SELECT * FROM table
Created 01-06-2016 11:05 PM
Thanks Neeraj. Is there any command to export all the data from the hive database into a flat file?
Created 01-07-2016 12:53 AM
Thanks Artem and Neeraj. I just copied the data from /apps/hive/warehouse to a local directory.
Note: Hive data is not necessary located in the folder mentioned above. i.e. external table can be defined anywhere within the HDFS. hive –e “DESCRIBE FORMATTED <tablename>” > <tablename_descformat>.txt;
This command is to collect detail information of tables. The detail information for a table includes column, partition, database it belongs, owner, create time, last access time, protect mode, location, table type, storage information and etc.
Created 01-07-2016 01:41 AM
yes correct, but if table is already external, then I don't see a point in need to sqoop data out of Hive as you can just work with those files directly.
Created 01-07-2016 01:42 AM
also as a good practice, since you achieved the intended result, please accept one of the answers you see fit to close out the thread.