ramnik bhatia
ramnik bhatia

Reputation: 59

How to change a particular column value for certain number of rows in Pig latin

I have a a pig file with say 10000 rows. Is there any quick way where I can change the value of a certain column for say first 1000 rows ?

Upvotes: 1

Views: 763

Answers (2)

Amnon
Amnon

Reputation: 2320

Since some info is missing, I will make a few assumptions, and then offer a solution.

  • by "first 1000 rows" you mean that you can order them records using some column
  • you which to change the value of column $1 in first 1000 records when ordering by column $2

The following code snippet will do what you asked for:

    a = load ...
    b = rank a by $2;
    c = foreach b generate $0, (rank_a<1000?$1:3*$1), $2..;

Upvotes: 1

Nag
Nag

Reputation: 339

Use For Each and Limit Operations to achieve the effect.

Upvotes: 0

Related Questions