2015-11-30 50 views
1

下面是我在做什么:输出到文件时,如何将结构编码为JSON?

INSERT OVERWRITE LOCAL DIRECTORY '/my/path' 
ROW FORMAT DELIMITED 
FIELDS TERMINATED BY ',' 
SELECT name, info 
FROM users 

info是一个嵌套的结构(类似于struct<struct<string, string>, int>的东西)。在输出文本文件中,我想将其编码为JSON。另外,我不能使用第三方UDF。

我该如何实现这个目标?

+0

Downvoter,请解释。 –

回答

0

尝试

insert overwrite local directory '/my/path' 
    row format serde 'org.apache.hadoop.hive.serde2.DelimitedJSONSerDe' 
    select name, info from users ; 

DelimitedJSONSerDe是内置蜂巢因此无需外部库。