2
votes

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?

2
Your answer is not really clear, ORC and Text are definitely not the same format. - Jérôme B
Hi, my question was I have an ORC managed table in hive and am not able to load ORC files which was created externally according to the table schema. - Sushil Ks
Is the external ORC file have the same schema than your Hive table ? - Jérôme B
Please add the following information: 1. What exactly did you do and how (relevant commands/code to make this reproducible). 2. What exactly goes wrong, do you get an error? - Dennis Jaheruddin

2 Answers

2
votes

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;
    
0
votes

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/';