简体   繁体   中英

How to load an ORC file created externally into HIVE Table stored as ORC?

I have created a managed hive table which is stored as ORC and when loading .txt files its working fine, however am not able to load an ORC file into that table. Is there anything to do with delimiters? or am i missing something?

Below code is working for me, while loading ORC files present in HDFS into a hive table.

  1. Create a table in hive.

     create table MyDB.TEST ( Col1 String, Col2 String, Col3 String, Col4 String) STORED AS INPUTFORMAT 'org.apache.hadoop.hive.ql.io.orc.OrcInputFormat' OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat';
  2. Load data to the table.

     LOAD DATA INPATH '/hdfs/dir/folder/to/orc/files/' INTO TABLE MyDB.TEST;

After several tries, here is the solution that works for me :

create table MyDB.TEST (
Col1 String,
Col2 String,
Col3 String,
Col4 String)
STORED AS ORC
LOCATION 'hdfs://hdfs/dir/folder/to/orc/files/';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM