所以我有制表符分隔数据的外部表。一个简单的表格如下所示:
create external table if not exists categories
(id string, tag string, legid string, image string, parent string, created_date string, time_stamp int)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'
LOCATION 's3n://somewhere/';
现在我在最后添加另一个字段,它将是一个以逗号分隔的值列表。
有没有办法以指定字段终止符的方式指定它,或者我是否必须依赖其中一个serdes?
例如:
...list_of_names ARRAY<String>)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' ARRAY ELEMENTS SEPARATED BY ','
...
(我假设我需要为此使用一个serde,但我认为在询问时没有任何伤害)
答案 0 :(得分:5)
我不知道如何更新现有表来执行此操作,而是创建表;您正在寻找的内容可以在https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL深入找到。 来自那里的片段
row_format
: DELIMITED [FIELDS TERMINATED BY char] [COLLECTION ITEMS TERMINATED BY char]
[MAP KEYS TERMINATED BY char] [LINES TERMINATED BY char]
我们创建表格的一个例子是
CREATE TABLE IF NOT EXISTS visits
(
... Columns Removed...
)
PARTITIONED BY (userdate STRING)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY '\001'
COLLECTION ITEMS TERMINATED BY '\002'
MAP KEYS TERMINATED BY '\003'
STORED AS TEXTFILE
;
您要查找的行是数组的COLLECTION ITEMS TERMINATED BY char
。
HTH