Write json data from hive to local file

This is my request in the hive.

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

This is how I export the data:

    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;

Here's what my data looks like after export:

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

I need to save json. it should be:

 {"data":"{\"age\":42, \"gender\":\"male\"}"}
+4
source share

Source: https://habr.com/ru/post/1684087/


All Articles