Support Questions
Find answers, ask questions, and share your expertise

Loading sequence files to Hive table

Solved Go to solution

Loading sequence files to Hive table

Rising Star

How Can I load a sequence file to an external table.

Looking for a help

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Loading sequence files to Hive table

Guru

Hi @Dinesh Das

You can do a CREATE EXTERNAL table as normal, but add the storage qualifier to it. For example:

create external table countries_ext_seq

LIKE countries_seq

STORED AS SEQUENCEFILE

LOCATION '/tmp/seqTest'

In the above example, I already have an existing hive table with the same columns and datatypes, so I use the lazy method by using the LIKE clause, but you can do the same with a full definition. I'm able to create this external table, point it to an existing sequence file stored in HDFS, and query with no problem.

As always, if you find this post useful, please "Accept" the answer.

View solution in original post

2 REPLIES 2

Re: Loading sequence files to Hive table

Guru

Hi @Dinesh Das

You can do a CREATE EXTERNAL table as normal, but add the storage qualifier to it. For example:

create external table countries_ext_seq

LIKE countries_seq

STORED AS SEQUENCEFILE

LOCATION '/tmp/seqTest'

In the above example, I already have an existing hive table with the same columns and datatypes, so I use the lazy method by using the LIKE clause, but you can do the same with a full definition. I'm able to create this external table, point it to an existing sequence file stored in HDFS, and query with no problem.

As always, if you find this post useful, please "Accept" the answer.

View solution in original post

Re: Loading sequence files to Hive table

New Contributor

You need to create external table then load data either from local or from HDFS.

CREATE EXTERNAL TABLE <table_name> (column1 <datatype>,column2 <datatype>,column3 <datatype>,...) ROW FORMAT DELIMITED STORED AS SEQUENCEFILE LOCATION '<location_path>';
Now Load data :

LOAD DATA INPATH '<HDFS PATH>' INTO <table_name>;