Search code examples
apache-pig

Convert the value of a column to uppercase in pig


I need to convert the value of a column to uppercase in pig.

Was able to do using UPPER but this creates a new column.

For example:

A = Load 'MyFile.txt' using PigStorage(',') as (column1:chararray, column2:chararray, column3:chararray);
Dump A;

Returns

a,b,c
d,e,f

Now I need to convert second column to upper case.

B = Foreach A  generate *,UPPER(column2);
Dump B;

returns

a,b,c,B
e,f,g,F

But I need

a,B,c
e,F,g

Please let me know if there is a way to so.


Solution

  • I didn't tried from my side but you can try like this

    B = Foreach A  generate column1,UPPER(column2),column3;