Created 08-25-2017 07:33 AM
Adding to @Sonu Sahi's reply, the CSVSerde is available in Hive 0.14 and greater. The following example creates a TSV (Tab-separated) file.
<code>CREATE
TABLE
my_table(a string, b string, ...)
ROW FORMAT SERDE
'org.apache.hadoop.hive.serde2.OpenCSVSerde'
WITH
SERDEPROPERTIES (
"separatorChar"
=
"\t"
,
"quoteChar"
=
"'"
,
"escapeChar"
=
"\\"
)
STORED
AS
TEXTFILE;
Default properties for SerDe is Comma-Separated (CSV) fileDEFAULT_ESCAPE_CHARACTER \
DEFAULT_QUOTE_CHARACTER "
DEFAULT_SEPARATOR ,
This SerDe works for most CSV data, but does not handle embedded newlines. To use the SerDe, specify the fully qualified class name org.apache.hadoop.hive.serde2.OpenCSVSerde.
If you want to use the TextFile format, then use 'ESCAPED BY' in the DDL.
"Enable escaping for the delimiter characters by using the 'ESCAPED BY' clause (such as ESCAPED BY '\')
Escaping is needed if you want to work with data that can contain these delimiter characters.
A custom NULL format can also be specified using the 'NULL DEFINED AS' clause (default is '\N')."