Search code examples
hivehiveqlhive-serde

In Hive ,how to specify semi-column delimiters for struct data types with in custom delimiters serde2


I am trying to create table as below.

CREATE TABLE r_test (foo INT, bar STRING, address  STRUCT<street:STRING, city:STRING, state:STRING, zip:INT>)
ROW FORMAT SERDE 'org.apache.hadoop.hive.contrib.serde2.MultiDelimitSerDe'
WITH SERDEPROPERTIES (
"field.delim"="<=>",
"collection.delim"="\;",
"mapkey.delim"="@"
    );

I getting error in created table as follows

Error: Error while compiling statement: FAILED: ParseException line 5:25 mismatched input '<EOF>' expecting StringLiteral near '=' in specifying key/value property (state=42000,code=40000)

Can someone please help?


Solution

  • Try with unicode character for semicolon i.e \u003B

    hive> CREATE TABLE r_test (foo INT, bar STRING, address  STRUCT<street:STRING, city:STRING, state:STRING, zip:INT>)
    ROW FORMAT SERDE 'org.apache.hadoop.hive.contrib.serde2.MultiDelimitSerDe'
    WITH SERDEPROPERTIES (
    "field.delim"="<=>",
    "collection.delim"="\u003B",
    "mapkey.delim"="@"
        );
    

    I created the table with unicode character and check the collection.delim is ; below:

    hive> desc formatted r_test;
        | Storage Desc Params:| NULL                 | NULL                        |
        |                     | collection.delim     | ;                           |
        |                     | field.delim          | <=>                         |
        |                     | mapkey.delim         | @                           |
        |                     | serialization.format | 1                           |