在Hive中,如何使用自定义定界符serde2为结构数据类型指定半列定界符

时间:2018-07-14 00:07:50

标签: hive hiveql hive-serde

我正在尝试创建如下表。

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"="@"
    );

我在创建的表中遇到如下错误

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)

有人可以帮忙吗?

1 个答案:

答案 0 :(得分:1)

尝试使用Unicode字符输入分号,即 \ 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"="@"
    );

我创建了具有Unicode字符的表,并检查了 collection.delim为; 如下:

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