Try generating the substring as a chararray and then casting it to int in another FOREACH.
On Fri, Sep 28, 2012 at 6:03 AM, Viswanathan K S <viswasiva2...@gmail.com>wrote: > Hi, > > > I am a newbie in Pig. > > Tried extracting a piece of string from a given text using substring and > made the extracted string as double. > > Then performing some mathematical functions on the extracted string throws > me an exception. > > Ex : > > Data : abc/123.34/-234.45,xxxx > def/122.45/-445.65,xxxx > ghi/223.45/-555.55,xxx > > Considering ‘ ,’ as the delimiter. > > a = load 'data' using PigStorage(‘,’) as (f1,f2); > > > > B = foreach a generate SUBSTRING(f1,4,10) as d1:double; > > > > Now if I compute some mathematical operation on d1, getting a > ClassCastException Error : > > > > “java.lang.ClassCastException : java.lang.String cannot be cast to > java.long.Double” > > > > Kindly help regarding the same. > > > Thanks and Regards, > > ksviswa > -- *Note that I'm no longer using my Yahoo! email address. Please email me at billgra...@gmail.com going forward.*