I have a hive table stored as a sequencefile.
I need to load a text file into this table. How do I load the data into this table?
I have a hive table stored as a sequencefile.
I need to load a text file into this table. How do I load the data into this table?
You cannot directly create a table stored as a sequence file and insert text into it. You must do this:
Example:
The simple way is to create table as textfile and move the file to the appropriate location
CREATE EXTERNAL TABLE mytable(col1 string, col2 string)
row format delimited fields terminated by '|' stored as textfile;
Copy the file to the HDFS Location where table is created.
Hope this helps!!!
You can load the text file into a textfile Hive table and then insert the data from this table into your sequencefile.
Start with a tab delimited file:
create a sequence file
try to load; as expected, this will fail:
But with this table:
The load works just fine:
Now load into the sequence table from the text table:
Can also do load/insert with overwrite to replace all.