Support Questions
Find answers, ask questions, and share your expertise

nested rank in pig

nested rank in pig

New Contributor

How to rank using pig within a group. I see there is JIRA for it "https://issues.apache.org/jira/browse/PIG-3279"

In Hive I am able to rank it within partitions.

But in pig how could this be done. Is there a work around.

Example in Hive:

select * from test_data;

test_data.month test_data.sale

month sale

501 35000.0

502 60000.0

501 40000.0

502 70000.0

501 35000.0

502 60000.0

select month, sale, RANK() OVER (PARTITION BY month ORDER BY sale DESC) AS rank FROM test_data GROUP BY month, sale;

month sale rank

501 40000.0 1

501 35000.0 2

502 70000.0 1

502 60000.0 2