Given that schema, you should be able to do this:

counts = FOREACH grpd {
  x = FILTER rawviews BY feature == 'some_feature';
  y = FILTER rawviews BY feature == 'some_other_feature';
  GENERATE FLATTEN(group) as (date, dist_partner, country, client_partner),
COUNT(x) as cnt_x, COUNT(y) as cnt_y;
};

Are you saying this isn't working? Can you send the actual script and sample
data?

-D

On Thu, Feb 25, 2010 at 11:41 AM, zaki rahaman <[email protected]>wrote:

> Are you talking about the relation just before the FOREACH? I get something
> like this:
>
> grpd: {group: (date: chararray,dist_partner: chararray,country:
> chararray,client_partner: chararray),rawviews: {date:
> chararray,dist_partner: chararray,country: chararray,client_partner:
> chararray,feature: chararray,userid: chararray}}
>
> I see the relation name I want to reference(rawviews) is a field in the
> tuple so not sure what's happening here. Basically I want to take the
> rawviews bag and split it based on a udf and then count the resulting
> splits.
>
> On Thu, Feb 25, 2010 at 2:34 PM, Dmitriy Ryaboy <[email protected]>
> wrote:
>
> > Zaki, throw in a "describe" on the relation you are trying to run the
> last
> > step on, and just check out what the disambiguated aliases are.
> >
> > -D
> >
> > On Thu, Feb 25, 2010 at 11:26 AM, zaki rahaman <[email protected]
> > >wrote:
> >
> > > For some reason, I am unable to filter inside my nested foreach. The
> > basic
> > > outline of my script is as follows:
> > >
> > > 1. Load input 1.
> > > 2. Load input 2.
> > > 3. Join input1 by key1, input2 by key2;
> > > 4. foreach joined generate fields + additional field named udf-field
> > (apply
> > > evalfunc udf to generate additional field);
> > > 5. group on (key2, key3, key4, key5)
> > > 6. FOREACH grouped  {
> > > FILTER relation BY udf-field == value
> > > FILTER relation BY  udf-field == value2
> > > FILTER relation BY udf-field == value3
> > > FILTER relation BY udf-field == value4
> > >
> > > Generate counts of each filtered relation;
> > >
> > > }
> > >
> > > --
> > > When I try to use the alias relation to reference my original relation
> > > (before the grouping in #5) I get a parsing error for an Invalid alias.
> > > What's the correct alias to use or can I not filter inside foreach?
> > >
> > >
> > > --
> > >
> > > Zaki Rahaman
> > >
> >
>
>
>
> --
> Zaki Rahaman
>

Reply via email to