Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Pig >> mail # user >> ERROR: java.lang.Long cannot be cast to java.lang.String


Copy link to this message
-
Re: ERROR: java.lang.Long cannot be cast to java.lang.String
Hi Sonia,

Try adding another pair of parenthesis-
eg-
((int)(RegexMatch((chararray) genre_id, '\\d+')) == 1 ? (chararray)genre_id
:
'-1001') as genre_id
On Thu, Aug 15, 2013 at 4:28 PM, sonia gehlot <[EMAIL PROTECTED]>wrote:

> Hi,
>
> I have pigscript in which I am flattening it and assign schema to it and
> trying to do some REGEX matching on top of it after that converting it to
> INT. But its giving me error "ERROR: java.lang.Long cannot be cast to java.
> lang.String"
>
> Here is a snippet of code where I am getting error:
> --------------------------------
>
> final_flatten = foreach flattened_further generate .. watched_evidence,
> flatten(myop) as (rank:int,list:chararray), row..device_type_id;
>
>
> final_cast = foreach final_flatten generate
>
> (int)dateint,
>
> (long)event_utc_ms,
>
> (int)hour,
>
> (long)(RegexMatch((chararray) account_id, '\\d+') == 1 ?
> (chararray)account_id
> : '-1001') as account_id,
>
> request_data_type,
>
> client_request_id,
>
> (int)(RegexMatch((chararray) device_type_id, '\\d+') == 1 ?
> (chararray)device_type_id
> : '-1001') as device_type_id,
>
> (int)(RegexMatch((chararray) max_list_index, '\\d+') == 1 ?
> (chararray)max_list_index
> : '-1001') as max_list_index,
>
> esn,
>
> (long)(RegexMatch((chararray) epoch_create_ts, '\\d+') == 1 ?
> (chararray)epoch_create_ts
> : '-1001') as request_create_ts,
>
> socially_connected,
>
> gps_model,
>
> country_iso_code,
>
> status_code,
>
> uuid,
>
> (long)(RegexMatch((chararray) visitorid, '\\d+') == 1 ?
> (chararray)visitorid: '-1001') as account_profile_id,
>
> (int)(RegexMatch((chararray) track_id, '\\d+') == 1 ? (chararray)track_id :
> '-1001') as location_id,
>
> sub_root_uuid,
>
> list_type,
>
> item_type,
>
> hasevidence,
>
> listContext,
>
> (int)(RegexMatch((chararray) genre_id, '\\d+') == 1 ? (chararray)genre_id :
> '-1001') as genre_id,
>
> taste_evidence,
>
> rated_evidence,
>
> watched_evidence,
>
> *(int)(RegexMatch((chararray) list, '\\d+') == 1 ? (chararray)list :
> '-1001') as source_title_id,*
>
> row as presentation_row_number,
>
> rank as presentation_rank_number;
>
> z = limit final_cast 10;
>
> dump z;
>
> ------------------------------------
>
> It is returning correct results other than one field
>
> "*(int)(RegexMatch((chararray) list, '\\d+') == 1 ? (chararray)list :
> '-1001') as source_title_id,*"
>
> for this I am getting error *"ERROR: java.lang.Long cannot be cast to java.
> lang.String"*
>
> I tried explicit casting, but it is still giving me error.
>
> Any idea what I am doing wrong here.
>
> Thanks,
>
> Sonia
>

--
"...:::Aniket:::... Quetzalco@tl"