You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pig.apache.org by Jerry Lam <ch...@gmail.com> on 2013/11/16 00:19:05 UTC

add a key value pair in map

Hi Pig users,

Do you know how to add a key value pair into a map?

For instance, a relation of A contains a document:map[] for each tuple;

B = foreach A generate document, ['newkey'#'newvalue'];

I want to add the 'newkey' and 'newvalue' inside the document map. Is it
possible?

Best Regards,

Jerry

Re: add a key value pair in map

Posted by Jerry Lam <ch...@gmail.com>.
Hi Pradeep,

Thanks for the pointer.

Jerry


On Fri, Nov 15, 2013 at 9:55 PM, Pradeep Gollakota <pr...@gmail.com>wrote:

> I don't think there's an out of the box solution for it. But it's fairly
> trivial to do with a UDF
> On Nov 15, 2013 3:19 PM, "Jerry Lam" <ch...@gmail.com> wrote:
>
> > Hi Pig users,
> >
> > Do you know how to add a key value pair into a map?
> >
> > For instance, a relation of A contains a document:map[] for each tuple;
> >
> > B = foreach A generate document, ['newkey'#'newvalue'];
> >
> > I want to add the 'newkey' and 'newvalue' inside the document map. Is it
> > possible?
> >
> > Best Regards,
> >
> > Jerry
> >
>

Re: add a key value pair in map

Posted by Pradeep Gollakota <pr...@gmail.com>.
I don't think there's an out of the box solution for it. But it's fairly
trivial to do with a UDF
On Nov 15, 2013 3:19 PM, "Jerry Lam" <ch...@gmail.com> wrote:

> Hi Pig users,
>
> Do you know how to add a key value pair into a map?
>
> For instance, a relation of A contains a document:map[] for each tuple;
>
> B = foreach A generate document, ['newkey'#'newvalue'];
>
> I want to add the 'newkey' and 'newvalue' inside the document map. Is it
> possible?
>
> Best Regards,
>
> Jerry
>