Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 Search Hadoop and all its subprojects:

Switch to Threaded View
Pig >> mail # user >> Class Cast Exception


Copy link to this message
-
Re: Class Cast Exception
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 <[EMAIL PROTECTED]>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
[EMAIL PROTECTED] going forward.*
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB