Concatenate a string in a field in a pig

Do I like the concatrow to all the data in the field?

The mydata sample dataset contains the following field. ( id, name, email )I like to add the string test prefix to all the data in the field name.

I tried

a = load 'mydata.csv' as (id, name, email);
b = foreach a generate id, concat('test', chararray(name)); 

I get empty results on this

any thoughts?

+4
source share
1 answer
  • Pigs concatshould Capital lettersnot contain small letters. You need to change the keyword concatto concat.
  • CSV (). , csv ? . csv , PigStorage.
  • , .

:

input.csv

1,aaa,user1@gmail.com
2,bbb,user2@gmail.com
3,ccc,user3@gmail.com

PigScript:

a = load 'input.csv' using PigStorage(',') as (id:int, name:chararray, email:chararray);
b = foreach a generate id, CONCAT('test', name);
DUMP b;

:

(1,testaaa)
(2,testbbb)
(3,testccc)

csv , concat.

+4

All Articles