Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]
Created 05-07-2016 08:23 PM
I have a simple data covering the salary in USD like "$36200" as chararray. I am trying to remove the leading $ symbol through the SUBSTRING function as below:
D = FOREACH C GENERATE SUBSTRING(wage, 1, SIZE(wage)) as wage_new;
I am getting an error like this:
ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1045: Could not infer the matching function for org.apache.pig.builtin.SUBSTRING as multiple or none of them fit. Please use an explicit cast.
However, if I am using the StopIndex of the SUBSTRING function explicitly, then the code compiles. But I would like to get to the end of the string dynamically.
Can somebody help me ?
Created 05-07-2016 08:50 PM
Hi @Subhasis Roy,
Substring wants Integer parameters while Size returns Long. Try casting the size to Int like this:
D = FOREACH C GENERATE SUBSTRING(wage, 1, (int)SIZE(wage)) as wage_new;
Created 05-07-2016 08:50 PM
Hi @Subhasis Roy,
Substring wants Integer parameters while Size returns Long. Try casting the size to Int like this:
D = FOREACH C GENERATE SUBSTRING(wage, 1, (int)SIZE(wage)) as wage_new;
Created 05-08-2016 07:38 AM
Great !! Thanks a lot for the help. It works now.