You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pig.apache.org by "David Ciemiewicz (JIRA)" <ji...@apache.org> on 2009/03/31 08:51:50 UTC
[jira] Created: (PIG-741) Add LIMIT as a statement that works in
nested FOREACH
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
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.
[jira] Updated: (PIG-741) Add LIMIT as a statement that works in
nested FOREACH
Posted by "Alan Gates (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/PIG-741?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Alan Gates updated PIG-741:
---------------------------
Resolution: Fixed
Status: Resolved (was: Patch Available)
Patch checked in.
> 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.
[jira] Commented: (PIG-741) Add LIMIT as a statement that works in
nested FOREACH
Posted by "Hadoop QA (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/PIG-741?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12704447#action_12704447 ]
Hadoop QA commented on PIG-741:
-------------------------------
-1 overall. Here are the results of testing the latest attachment
http://issues.apache.org/jira/secure/attachment/12406856/PIG-741.patch
against trunk revision 768923.
+1 @author. The patch does not contain any @author tags.
+1 tests included. The patch appears to include 3 new or modified tests.
+1 javadoc. The javadoc tool did not generate any warning messages.
+1 javac. The applied patch does not increase the total number of javac compiler warnings.
-1 findbugs. The patch appears to introduce 3 new Findbugs warnings.
+1 release audit. The applied patch does not increase the total number of release audit warnings.
-1 core tests. The patch failed core unit tests.
+1 contrib tests. The patch passed contrib unit tests.
Test results: http://hudson.zones.apache.org/hudson/job/Pig-Patch-minerva.apache.org/28/testReport/
Findbugs warnings: http://hudson.zones.apache.org/hudson/job/Pig-Patch-minerva.apache.org/28/artifact/trunk/build/test/findbugs/newPatchFindbugsWarnings.html
Console output: http://hudson.zones.apache.org/hudson/job/Pig-Patch-minerva.apache.org/28/console
This message is automatically generated.
> 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.
[jira] Updated: (PIG-741) Add LIMIT as a statement that works in
nested FOREACH
Posted by "Alan Gates (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/PIG-741?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Alan Gates updated PIG-741:
---------------------------
Attachment: PIG-741.patch
> 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.
[jira] Commented: (PIG-741) Add LIMIT as a statement that works in
nested FOREACH
Posted by "Alan Gates (JIRA)" <ji...@apache.org>.
[ 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.
[jira] Commented: (PIG-741) Add LIMIT as a statement that works in
nested FOREACH
Posted by "David Ciemiewicz (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/PIG-741?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12704735#action_12704735 ]
David Ciemiewicz commented on PIG-741:
--------------------------------------
Because this is a "new" feature, we probably need to make some edits to the Pig reference manual when this is released.
> 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.
[jira] Assigned: (PIG-741) Add LIMIT as a statement that works in
nested FOREACH
Posted by "Alan Gates (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/PIG-741?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Alan Gates reassigned PIG-741:
------------------------------
Assignee: Alan Gates
> 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
>
> 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.
[jira] Updated: (PIG-741) Add LIMIT as a statement that works in
nested FOREACH
Posted by "Alan Gates (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/PIG-741?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Alan Gates updated PIG-741:
---------------------------
Fix Version/s: 0.3.0
Status: Patch Available (was: Open)
A patch that adds the ability to have limit nested in a foreach. This first version does not use the combiner.
> 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.
[jira] Commented: (PIG-741) Add LIMIT as a statement that works in
nested FOREACH
Posted by "Alan Gates (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/PIG-741?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12704775#action_12704775 ]
Alan Gates commented on PIG-741:
--------------------------------
I only added tests for local mode because inner operators are executed in local mode one way or another, so I didn't think there was a need to test it in the map reduce case as well.
> 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.
[jira] Commented: (PIG-741) Add LIMIT as a statement that works in
nested FOREACH
Posted by "David Ciemiewicz (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/PIG-741?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12704452#action_12704452 ]
David Ciemiewicz commented on PIG-741:
--------------------------------------
Thanks Alan!
The fact that LIMIT in this case doesn't use the combiner is probably not an issue. In most of the instances I have, I usually don't have more than a million things in the grouped databag, most of the time I only have under 1000 to 10000 things so the combiner won't have much value.
> 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.
[jira] Commented: (PIG-741) Add LIMIT as a statement that works in
nested FOREACH
Posted by "Olga Natkovich (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/PIG-741?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12704685#action_12704685 ]
Olga Natkovich commented on PIG-741:
------------------------------------
+1 on the patch with one question: is there a reason why tests were only added for local mode?
> 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.