Reputation: 29
I am trying to write a pig script which has date in the format 04/15/2016. I want to convert it to 04-15-2016
. I am getting when I do the below:
x=REPLACE(date,'\','-');
dump x;
I want to know the correct way of writing this.
Thanks, stacky
Upvotes: 0
Views: 316
Reputation: 11080
Cast the field as chararray in REPLACE.
REPLACE(string, 'oldChar', 'newChar');
X = FOREACH A GENERATE REPLACE((chararray)date,'/','-');
dump X;
Upvotes: 0
Reputation: 123
This should work.
X = FOREACH A GENERATE REPLACE(date,'/','-');
DUMP X;
Upvotes: 0