HIVE insert overwrite directory with json format HIVE insert overwrite directory with json format hadoop hadoop

HIVE insert overwrite directory with json format


It seems your issue with a workaround (using JsonUDF with named_struct) is described here: https://github.com/rcongiu/Hive-JSON-Serde/issues/151

extract.hql:add jar /home/myuser/lib/json-udf-1.3.8-SNAPSHOT-jar-with-dependencies.jar;create temporary function tjson as 'org.openx.data.udf.JsonUDF';insert overwrite local directory '/json/'selecttjson(named_struct("name", t.name,"nickname", t.nickname))from tb_test t;

Also you can create JsonSerDe-based table with columns defined, insert overwrite it and use table location instead of directory.


I ran into this today. In case you don't want/can't use UDFs,using this guideline: https://docs.aws.amazon.com/athena/latest/ug/json-serde.html,this worked for me (order of column should be different also using the mapping prefix:

insert overwrite directory '/json/'ROW FORMAT SERDE 'org.openx.data.jsonserde.JsonSerDe'WITH SERDEPROPERTIES ( "case.insensitive" = "false", "mapping._col0" = "stat_name", "mapping._col1" = "stat_interval")select name, nicknamefrom tb_test limit 100