I like to concat
a string to all data in a field?
example a dataset mydata contains following field ( id, name, email )
i like to add a prefix of string test 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'm getting empty results on this
any thoughts ?
concat
keyword should be in Capital letters
not small letters. You need to change the keyword concat
to CONCAT
.Sample example:
input.csv
1,aaa,[email protected]
2,bbb,[email protected]
3,ccc,[email protected]
PigScript:
a = load 'input.csv' using PigStorage(',') as (id:int, name:chararray, email:chararray);
b = foreach a generate id, CONCAT('test', name);
DUMP b;
Output:
(1,testaaa)
(2,testbbb)
(3,testccc)
Incase your csv file is already tab separated delimiter then fix only the CONCAT
issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With