Support Questions

Find answers, ask questions, and share your expertise

How to convert ORC file into CSV, or how to create a table in hive with an orc file ?

avatar
New Contributor

Hi,

I'm new on hadoop and today I try to create a csv file from an orc file.

I can display orc contents with :

hive --orcfiledump file:///root/myORCfile

and I got another text file with the original table structure (col names, types etc..) created from a "describe table" sql command.

I also know how to export a table from hive to a local csv.

However, I'm wondering if it exists any solution to convert my orc file into a simple hive table. I also try to know if it is possible to directly convert orc to csv.

3 REPLIES 3

avatar

@Christopher Daumer

Create an external hive table with ORC and point it to your ORC file location.

CREATE EXTERNAL TABLE IF NOT EXISTS mytable 
(col1 bigint,col2 bigint) ROW FORMAT DELIMITED
    FIELDS TERMINATED BY ','
STORED AS ORC
    location '<ORC File location';

I dont think you can convert an ORC into csv directly. But you can write an UDF to do it.

avatar
New Contributor

HI @Bala Vignesh N V

Thanks a lot for your answer. When I execute your query, I get almost only NULL values within my table (other are kind of binaries data). I also tried with :

"orc.compress"="ZLIB" and "orc.compress.size"=65536 But nothing changed. Any ideas ?

avatar

@Christopher Daumer

Check the delimiter which you used in creating external table is correct.

Also could you share the sample data and DDL which you have used to create the hive table? I dont think the compression property or size will be the reason for the issue.