将json数据从hive写入本地文件

时间:2017-08-21 03:32:38

标签: hadoop hive amazon-emr

这是我在hive中的查询

select colname from uber_test;
OK
{"data":"{\"age\":42, \"gender\":\"male\"}"}

这是我导出数据的方式:

    CREATE TABLE export_test_1( name STRING) ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' STORED AS TEXTFILE;
    INSERT OVERWRITE LOCAL DIRECTORY 'export_test_1' ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' select colname from uber_test;

这是我导出后的数据:

more export_test_2/000000_0 
data{"age":42, "gender":"male"}

我需要保留json。需要:

 {"data":"{\"age\":42, \"gender\":\"male\"}"}

0 个答案:

没有答案