Use a SerDe to create a table
To use a SerDe when creating a table in Athena, use one of the following methods:
-
Specify
ROW FORMAT DELIMITED
and then use DDL statements to specify field delimiters, as in the following example. When you specifyROW FORMAT DELIMITED
, Athena uses the LazySimpleSerDe by default.ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' ESCAPED BY '\\' COLLECTION ITEMS TERMINATED BY '|' MAP KEYS TERMINATED BY ':'
For examples of
ROW FORMAT DELIMITED
, see the following topics: -
Use
ROW FORMAT SERDE
to explicitly specify the type of SerDe that Athena should use when it reads and writes data to the table. The following example specifies the LazySimpleSerDe. To specify the delimiters, useWITH SERDEPROPERTIES
. The properties specified byWITH SERDEPROPERTIES
correspond to the separate statements (likeFIELDS TERMINATED BY
) in theROW FORMAT DELIMITED
example.ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe' WITH SERDEPROPERTIES ( 'serialization.format' = ',', 'field.delim' = ',', 'collection.delim' = '|', 'mapkey.delim' = ':', 'escape.delim' = '\\' )
For examples of
ROW FORMAT SERDE
, see the following topics: