You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hive.apache.org by Avishay Livne <AV...@il.ibm.com> on 2009/09/17 14:52:31 UTC

saving table into local file as textfile

Hi,

I am trying to save a table into a local file as a text file (as opposed to
binary file).
I use the following command

INSERT OVERWRITE LOCAL DIRECTORY '/path/to/file' SELECT * FROM table1;

instead of creating a text file in the supplied path, a folder in the same
path is created with the following 4 files inside it
attempt_200909161021_0059_m_000000_0
attempt_200909161021_0059_m_000001_0
.attempt_200909161021_0059_m_000000_0.crc
.attempt_200909161021_0059_m_000001_0.crc
all the files are binary files and the content of the first two files
appears to be the content of the table.

To create the table I used
CREATE TABLE table1 (a STRING, b STRING) ROW FORMAT DELIMITED FIELDS
TERMINATED BY '\t' STORED AS TEXTFILE;

Could anyone explain me how to force Hive to save the table in text format
rather than binary?

Thanks,
Avishay


Re: saving table into local file as textfile

Posted by Zheng Shao <zs...@gmail.com>.
.crc files are checksum files by hadoop. They can be ignored.

The first 2 files (non-crc) ARE text files - just replace Ctrl-A (^A, ascii
code 1) with TAB, then you get what you want.


Zheng

On Thu, Sep 17, 2009 at 5:52 AM, Avishay Livne <AV...@il.ibm.com> wrote:

>
> Hi,
>
> I am trying to save a table into a local file as a text file (as opposed to
> binary file).
> I use the following command
>
> INSERT OVERWRITE LOCAL DIRECTORY '/path/to/file' SELECT * FROM table1;
>
> instead of creating a text file in the supplied path, a folder in the same
> path is created with the following 4 files inside it
> attempt_200909161021_0059_m_000000_0
> attempt_200909161021_0059_m_000001_0
> .attempt_200909161021_0059_m_000000_0.crc
> .attempt_200909161021_0059_m_000001_0.crc
> all the files are binary files and the content of the first two files
> appears to be the content of the table.
>
> To create the table I used
> CREATE TABLE table1 (a STRING, b STRING) ROW FORMAT DELIMITED FIELDS
> TERMINATED BY '\t' STORED AS TEXTFILE;
>
> Could anyone explain me how to force Hive to save the table in text format
> rather than binary?
>
> Thanks,
> Avishay
>
>


-- 
Yours,
Zheng