You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pig.apache.org by "liyunzhang_intel (JIRA)" <ji...@apache.org> on 2016/05/10 08:37:13 UTC

[jira] [Commented] (PIG-4883) java.lang.ClassCastException: org.apache.pig.data.BinSedesTuple cannot be cast to java.lang.Long

    [ https://issues.apache.org/jira/browse/PIG-4883?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15277804#comment-15277804 ] 

liyunzhang_intel commented on PIG-4883:
---------------------------------------

   the problem in the above case is because if the map key type of all splittees are not same, we just use Tuple to set the map key type of splitter.
   But it will meet problem in following case:
{noformat}
                      A        B                 C        D
                       \      /                   \     /
                     Splitter(E)                 Splitter(F)
                            \                       /
                                 Slitter(G)
                 If the mapKeyType of A and B are not same, mapKeyType of E will be Tuple
                 If the mapKeyType of C and D are not same, mapKeyType of F will be Tuple
                 we will consider G hasSameMapKeyType but actually not.
{noformat}

In above case, the value of splitter's hasSameMapKeyType is true. It causes the key is not unwrapped in MultiQueryPackager#getNext
{code}
  @Override
    public Result getNext() throws ExecException {
        ....
        // check to see if we need to unwrap the key. The keys may be
        // wrapped inside a tuple by LocalRearrange operator when jobs
        // with different map key types are merged
        PigNullableWritable curKey = keyWritable;
        if (!sameMapKeyType && !inCombiner && isKeyWrapped.get(index)) {
            Tuple tup = (Tuple) keyWritable.getValueAsPigType();
            curKey = HDataType.getWritableComparableTypes(tup.get(0),
                    pkgr.getKeyType());
            curKey.setIndex(origIndex);
        }
.....
{code}
   
[~rohini] or [~daijy]: can you help review this patch?            

>  java.lang.ClassCastException: org.apache.pig.data.BinSedesTuple cannot be cast to java.lang.Long
> -------------------------------------------------------------------------------------------------
>
>                 Key: PIG-4883
>                 URL: https://issues.apache.org/jira/browse/PIG-4883
>             Project: Pig
>          Issue Type: Bug
>    Affects Versions: 0.15.0
>            Reporter: swlai
>            Assignee: liyunzhang_intel
>
> The following code and data will raise an exception.
> However, if I remove any of the four "store"s, the code will be fine.
> {code:title=test.pig|borderStyle=solid}
> r = load 'test.txt' as (id: chararray, val: long);
> t1 = filter r by val >= 12 and val < 20;
> grpd = group t1 by val;
> t1_cnt = foreach grpd generate group as name, COUNT(t1) as value;
> t1_cnt = foreach t1_cnt generate (chararray)name, value;
> grpd = group t1 all;
> t1_cnt_total = foreach grpd generate 't1' as name, COUNT(t1) as value; 
> t2 = filter r by val >= 20 and val < 30;
> grpd = group t2 by val;
> t2_cnt = foreach grpd generate group as name, COUNT(t2) as value;
> --t2_cnt = foreach t2_cnt generate (chararray)name, value;
> grpd = group t2 all;
> t2_cnt_total = foreach grpd generate 't2' as name, COUNT(t2) as value;
> store t1_cnt  into 'outx/3';
> store t2_cnt  into 'outx/4';
> store t1_cnt_total into 'outx/5';
> store t2_cnt_total into 'outx/6';
> {code}
> and
> {code:title=test.txt|borderStyle=solid}
> c	12
> {code}
> will cause error:
> Caused by: java.lang.ClassCastException: org.apache.pig.data.BinSedesTuple cannot be cast to java.lang.Long
>         at org.apache.pig.backend.hadoop.executionengine.physicalLayer.expressionOperators.POCast.getNextString(POCast.java:1167)
>         at org.apache.pig.backend.hadoop.executionengine.physicalLayer.PhysicalOperator.getNext(PhysicalOperator.java:343)
>         ... 14 more
> I don't know why the code need to cast a BinSedesTuple to Long.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)