我有下面的Pig袋子和两个元组。
{(1,'Kumar','23000','Kandy')}
{(2,'Mahela','34000','Colombo')}
如何使用pig将上述内容转换为以下json键值格式?
{
1: 'kumar,23000,kandy',
2: 'mahela',34000,'colombo'
}
任何帮助都将不胜感激。请注意,我需要将其存储在一个json文件中
在奥利弗的回答之后
{"fields":[{"name":"group","type":10,"description":"autogenerated from Pig Field Schema","schema":null},{"name":"test_table_columns_needed","type":120,"description":"autogenerated from Pig Field Schema","schema":{"fields":[{"name":null,"type":110,"description":"autogenerated from Pig Field Schema","schema":{"fields":[{"name":"id","type":10,"description":"autogenerated from Pig Field Schema","schema":null},{"name":"name","type":55,"description":"autogenerated from Pig Field Schema","schema":null},{"name":"salary","type":55,"description":"autogenerated from Pig Field Schema","schema":null},{"name":"destination","type":55,"description":"autogenerated from Pig Field Schema","schema":null}],"version":0,"sortKeys":[],"sortKeyOrders":[]}}],"version":0,"sortKeys":[],"sortKeyOrders":[]}}],"version":0,"sortKeys":[],"sortKeyOrders":[]} {"group":1,"test_table_columns_needed":[{"id":1,"name":"'Kumar'","salary":"'23000'","destination":"'Kandy'"}]}
{"group":2,"test_table_columns_needed": [{"id":2,"name":"'Mahela'","salary":"'34000'","destination":"'Colombo'"}]}
2条答案
按热度按时间rdrgkggo1#
这里有一种方法根据输入数据
llew8vvj2#
修改file.pig\u模式以符合元组输入。