Hive array(struct()) to JSON -


in attempt fix hive/json team, blocked getting following work correctly.

given:

hive table

create table bob( createdt bigint, profile array<struct<user_id:string,empno:int>> )  [{"user_id":"sally","empno":5}], [{"user_id":"billy","empno":6}], [{"user_id":"fred","empno":7}], 

the goal following:

{ "createdt": "123456789", "users": [ { "user_id": "sally", "empno": 5, }, { "user_id": "billy", "empno": 6, }, { "user_id": "fred", "empno": 7, } ] }

i using brickhouse udf , have far:

create temporary function to_json 'brickhouse.udf.json.tojsonudf'; create temporary function from_json 'brickhouse.udf.json.fromjsonudf'; create temporary function collect 'brickhouse.udf.collect.collectudaf';  select  to_json(named_struct("createdt", a.createdt, "users",array(named_struct("user_id", a.user_id,"empno",a.empno) bob  

this giving me:

"createdt": 123456789, "users":[{"user_id":["sally","billy","fred"}] 

anyone have solution ?


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -