Thanks for the responses, I think Dmitriy has the right answer as even
after digging through lots of Pig JavaDocs, there doesn't seem to be a
containment clause.

I need the following:

r1: {(a), (b), (c)}, (b)
r2: {(z), (c)}, (f)
r3: {(a)}, (a)

I want to filter based on Bag B CONTAINS Tuple T, i.e. in this case I'd
only be interested in r1 & r3. as the tuple outside the bag is also
contained within. So size has nothing to do with it nor does the IsEmpty...
I'll just write it as a UDF but would have assumed there was a way to do
this already, given that it should be a fairly common thing?

Thanks!
Flo



On Mon, Feb 13, 2012 at 1:06 PM, Russell Jurney <[email protected]>wrote:

> Won't SIZE() count the tuples in a bag, and return 0 if it is empty?
>
> On Feb 13, 2012, at 1:02 PM, Dmitriy Ryaboy <[email protected]> wrote:
>
> > Flo, how do you want to test for containment -- based on tuple fields?
> > That doesn't exist afaik (contributions welcome). It'd be fairly trivial
> to
> > write.
> >
> >
> > On Mon, Feb 13, 2012 at 11:15 AM, Prashant Kommireddi
> > <[email protected]>wrote:
> >
> >> IsEmpty is the function you might be looking for
> >> http://pig.apache.org/docs/r0.9.1/func.html#isempty
> >>
> >> Thanks,
> >> Prashant
> >>
> >> On Mon, Feb 13, 2012 at 9:41 AM, Flo Leibert <
> [email protected]
> >>> wrote:
> >>
> >>> Hi -
> >>> Is there a good way to see if a bag contains a tuple? Given a record
> that
> >>> has a tuple T and a Bag (a bag could contain 0 to n tuples), how do I
> >>> filter the records where the bag contains the tuple?
> >>>
> >>> I could write a custom UDF but Pig probably has a built-in function
> that
> >>> takes care of this? Looked at the list of built-in functions but
> couldn't
> >>> identify one - afaict, there's not "CONTAINS" function.
> >>>
> >>> Any pointers would be appreciated!
> >>>
> >>> Thanks,
> >>> florian
> >>>
> >>
>

Reply via email to