Dan
Dan

Reputation: 45

pig order by with rank and join the rank together

I have the following data with the schema (t0:chararray, t1:int)

a0 1
a1 7
b2 9
a2 4
b0 6

And I want to order it t1 and then combine with a rank

a0 1 1
a2 4 2
b0 6 3
a1 7 4
b2 9 5

Is there any convenient way without writing UDF in pig?

Upvotes: 0

Views: 333

Answers (1)

Frederic
Frederic

Reputation: 3284

There is the RANK operation in Pig. This should be sufficient:

X = rank A by t1 ASC;

Please see the Pig docs for more details.

Upvotes: 1

Related Questions