You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pig.apache.org by "Daniel Dai (Commented) (JIRA)" <ji...@apache.org> on 2011/09/30 22:05:45 UTC
[jira] [Commented] (PIG-2311) Class cast exception thrown in
STRSPLIT even after casting properly
[ https://issues.apache.org/jira/browse/PIG-2311?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13118354#comment-13118354 ]
Daniel Dai commented on PIG-2311:
---------------------------------
In addition, foreach does achieve the intention.
A1 = foreach A1 generate a as a:chararray ;
a:chararray does not actually do the type conversion. This is a known issue and need clarification on the Pig grammar.
> Class cast exception thrown in STRSPLIT even after casting properly
> -------------------------------------------------------------------
>
> Key: PIG-2311
> URL: https://issues.apache.org/jira/browse/PIG-2311
> Project: Pig
> Issue Type: Bug
> Affects Versions: 0.9.0
> Reporter: Anitha Raju
> Fix For: 0.10
>
>
> Hi,
> The below script treats 'a' as bytearray thus throwing class cast exception at STRSPLIT
> =========
> A = load 'input.txt' using PigStorage() as (a);
> A1 = filter A by NOT (a is null);
> A1 = foreach A1 generate a as a:chararray ;
> describe A1;
> B = foreach A1 generate STRSPLIT(a);
> dump B
> =========
> Input.txt (space separated)
> =========
> a b
> =========
> Here i am casting as "a as a:chararray". If you see the output of describe it gives
> A1: {a: chararray}
> When its passed in STRSPLIT, it treats as a bytearray thus throwing the following exception in the task logs
> =======
> WARN org.apache.pig.builtin.STRSPLIT: class cast exception at org.apache.pig.builtin.STRSPLIT.exec(STRSPLIT.java:55)
> =======
> hence giving null output at B.
> If we cast 'a' using
> =========
> A1 = foreach A1 generate (chararray)a as a ;
> =========
> it gives the correct output.
> ((a,b))
> In both the cases the describe gives
> A1: {a: chararray}
> Regards,
> Anitha
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira