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

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


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 ORCLOCATION 'hdfs://hdfs/dir/folder/to/orc/files/';