[
https://issues.apache.org/jira/browse/PIG-741?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12704672#action_12704672
]
Alan Gates commented on PIG-741:
--------------------------------
Since limit distributes rather nicely, I'd very much like it to use the
combiner. But after looking at the code for a bit I realized I could wait for
the work Santosh is doing on the optimizer and use that (see PIG-697) or
rewrite a bunch of that code myself. I decided it was better to check in a
limited version of limit (hah) now and get the combiner functionality in a
month or two. Glad to hear it will work for you now.
> Add LIMIT as a statement that works in nested FOREACH
> -----------------------------------------------------
>
> Key: PIG-741
> URL: https://issues.apache.org/jira/browse/PIG-741
> Project: Pig
> Issue Type: New Feature
> Reporter: David Ciemiewicz
> Assignee: Alan Gates
> Fix For: 0.3.0
>
> Attachments: PIG-741.patch
>
>
> I'd like to compute the top 10 results in each group.
> The natural way to express this in Pig would be:
> {code}
> A = load '...' using PigStorage() as (
> date: int,
> count: int,
> url: chararray
> );
> B = group A by ( date );
> C = foreach B {
> D = order A by count desc;
> E = limit D 10;
> generate
> FLATTEN(E);
> };
> dump C;
> {code}
> Yeah, I could write a UDF / PiggyBank function to take the top n results. But
> since LIMIT already exists as a statement, it seems like it should also work
> in the nested foreach context.
> Example workaround code.
> {code}
> C = foreach B {
> D = order A by count desc;
> E = util.TOP(D, 10);
> generate
> FLATTEN(E);
> };
> dump C;
> {code}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.