You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hive.apache.org by "Omer, Farah" <fo...@microstrategy.com> on 2012/03/06 17:32:00 UTC

How to get a flat file out of a table in Hive

Whats the easiest way to get a flat file out from a table in Hive?

I have a table in HIVE, that has millions of rows. I want to get a dump of this table out in flat file format, and it should be comma separated.

Anyone knows the syntax to do it?

Thanks for the help!

Farah Omer

Senior DB Engineer, MicroStrategy, Inc.
T: 703 2702230
E: fomer@microstrategy.com<ma...@microstrategy.com>
http://www.microstrategy.com




RE: How to get a flat file out of a table in Hive

Posted by "hezhiqiang (Ransom)" <ra...@huawei.com>.
you can create table as select first, use comma separated.
Then export it.


Best regards
Ransom.

From: Omer, Farah [mailto:fomer@microstrategy.com]
Sent: Wednesday, March 07, 2012 12:32 AM
To: user@hive.apache.org
Subject: How to get a flat file out of a table in Hive

Whats the easiest way to get a flat file out from a table in Hive?

I have a table in HIVE, that has millions of rows. I want to get a dump of this table out in flat file format, and it should be comma separated.

Anyone knows the syntax to do it?

Thanks for the help!

Farah Omer

Senior DB Engineer, MicroStrategy, Inc.
T: 703 2702230
E: fomer@microstrategy.com<ma...@microstrategy.com>
http://www.microstrategy.com




Re: How to get a flat file out of a table in Hive

Posted by Jonathan Seidman <jo...@gmail.com>.
Farah – The easiest way to dump data to a file is with a query like the
following:

hive> INSERT OVERWRITE LOCAL DIRECTORY 'DIRECTORY_NAME' SELECT * from
TABLE_NAME;

The drawback of this is that Hive uses ^A as the separator by default. In
the past what I found easiest was to just run a simple sed script on the
output file to replace the ^A's with another character. For example:

sed -e 's/\A/,/g' FILE > FILE.NEW

That's from memory, so I'm not guaranteeing the syntax of the sed command,
but I think it's basically correct.

Jonathan

On Tue, Mar 6, 2012 at 10:32 AM, Omer, Farah <fo...@microstrategy.com>wrote:

>  Whats the easiest way to get a flat file out from a table in Hive?
>
> I have a table in HIVE, that has millions of rows. I want to get a dump of
> this table out in flat file format, and it should be comma separated.
>
> Anyone knows the syntax to do it?
>
> Thanks for the help!
>
> *Farah Omer*
>
> *Senior DB Engineer, MicroStrategy, Inc.*
> T: 703 2702230
> E: *fomer@microstrategy.com* <fo...@microstrategy.com>
> *http://www.microstrategy.com* <http://www.microstrategy.com>
>
>
>
>