You are on page 1of 3

What is Hive Serde?

Serde is short for Serializer/Deserializer. Hive uses the Serde interface for IO.
The interface handles both serialization and deserialization and also
interpreting the results of serialization as individual fields for processing.
Reading from HDFS
HDFS files –> InputFileFormat –> <key, value> –> Deserializer –> Row object
Writing to HDFS
Row object –> Serializer –> <key, value> –> OutputFileFormat –> HDFS files

 Basically, to read and write HDFS files Hive uses these


FileFormat classes currently:

 TextInputFormat/HiveIgnoreKeyTextOutputFormat
It read/write data in plain text file format.
 SequenceFileInputFormat/SequenceFileOutputFormat
It read/write data in Hadoop SequenceFile format.
 MetadataTypedColumnsetSerDe
So, to read/write delimited records we use this Hive Serde. Such as CSV,
tab-separated control-A separated records (sorry, quote is not
supported yet).

 LazySimpleSerDe
Also, to read the same data format as MetadataTypedColumnsetSerDe.
Moreover, it creates Objects in a lazy way. Hence, that offers better
performance.
 Built-in SerDes

 Avro 
 ORC 
 Parquet 
 CSV 
 JsonSerde

create external table wc_csvserde_tb

id int,

name string,

salary float,

address string,

city string

row format serde 'org.apache.hadoop.hive.serde2.OpenCSVSerde'

with serdeproperties(

"separator char "=",",

"quotechar"="\""

tblproperties('skip.header.line.count'='1');

 hadoop@hadoop:~$ ls /home/hadoop/Desktop/wc_session.csv

/home/hadoop/Desktop/wc_session.csv
 hive (bwt_session)> desc wc_csvserde_tb;

OK

id string from deserializer

name string from deserializer

salary string from deserializer

address string from deserializer

city string from deserializer

Time taken: 0.093 seconds, Fetched: 5 row(s)

 hive (bwt_session)> load data local inpath


'/home/hadoop/Desktop/wc_session.csv' into table wc_csvserde_tb;

Loading data to table bwt_session.wc_csvserde_tb

OK

Time taken: 0.533 seconds

 hive (bwt_session)> select * from wc_csvserde_tb;


OK
1 Ram 40000 Sigara Banaras
2 Laxman 50000 Ramnagar Vapi
3 sham 60000 Rampur Varanasi
4 kishan 30000 Nerhe Pune

You might also like