Search code examples
javahadoopapache-pigudf

Apply Pig UDF on single column and automatically generate all other columns


I have a Pig UDF that converts Ebcidic characters to ASCII in my pipe separated data file. I have hundreds of columns and I want my UDF to be applied on 70th column. How can I apply the UDF on that particular column and get the column data replaced as ASCII in the dataset.

REGISTER pigudf-0.0.1.jar;
DEFINE Ebc2Asc com.z.pig.udf.Ebc2Asc;

A = LOAD '/user/T4/cobDump.txt' USING PigStorage('|');
B = FOREACH A GENERATE Ebc2Asc($71) as txt:chararray;
DUMP B;

If we call the script like above I am getting only the converted column as part of the result. How can I get all the columns along with the applied udf column.

Any help appreciated.


Solution

  • It has been a while, but it sounds like you want to use a range projection to automatically generate the other columns. It should look something like:

    B = FOREACH A GENERATE $0 .. $70, Ebc2Asc($71) as txt:chararray, $72 .. ;