Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache Hive: Convert Map<string,string> to a json string?

What is the easiest way in Apache Hive to convert a Map (String, String) to a string representation in json format?

I've tried reflect and the JSONValue class, but it seems that the reflect udf only accepts primitives datatypes...

Your help is highly appreciated.

Kind regards Dennis

like image 747
Dennis Avatar asked Sep 11 '26 23:09

Dennis


1 Answers

Just use the "to_json" UDF from Brickhouse. ( http://github.com/klout/brickhouse ). It converts any arbitrary Hive structure into valid JSON. You can also parse arbitrary JSON formats into Hive structures with the "from_json" UDF.

like image 138
Jerome Banks Avatar answered Sep 14 '26 06:09

Jerome Banks