...
NOTE: Apache Hive recommends that custom ObjectInspectors created for use with custom SerDes have a no-argument constructor in addition to their normal constructors for serialization purposes. See HIVE-5380 for more details.
Registration of Native SerDe's
As of Hive 0.14 a registration mechanism has been introduced for native Hive SerDe's to bind 'STORED AS' syntax naturally as a shorthand for a triplet of SerDe, InputFormat, and OutputFormat specification in CreateTable statement.
The following mappings have been added:
Syntax | Equivalent |
---|---|
STORED AS AVRO | ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.avro.AvroSerDe' STORED AS INPUTFORMAT 'org.apache.hadoop.hive.ql.io.avro.AvroContainerInputFormat' OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.avro.AvroContainerOutputFormat' |
STORED AS ORC/ STORED AS ORCFILE | ROW FORMAT SERDE
' STORED AS INPUTFORMAT
' OUTPUTFORMAT
' |
STORED AS PARQUET/ STORED AS PARQUETFILE | ROW FORMAT SERDE
' STORED AS INPUTFORMAT
' OUTPUTFORMAT
' |
STORED AS RCFILE | STORED AS INPUTFORMAT org.apache.hadoop.hive.ql.io.RCFileInputFormat' OUTPUTFORMAT
' |
STORED AS TEXTFILE | STORED AS INPUTFORMAT
' OUTPUTFORMAT
|
To add a new native SerDe with STORED AS syntax, follow these steps:
Create a class extending from AbstractStorageFormatDescriptor.java that returns a stored as keyword to {InputFormat, OutputFormat, SerDe} triplet mapping
Add the name of the class to StorageFormatDescriptor registration file.
MetaStore
MetaStore contains metadata regarding tables, partitions and databases. This is used by Query Processor during plan generation.
...