You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pig.apache.org by "Luis Guerra (JIRA)" <ji...@apache.org> on 2015/10/01 15:33:26 UTC

[jira] [Created] (PIG-4687) Trouble ordering bigdecimal data within a foreach

Luis Guerra created PIG-4687:
--------------------------------

             Summary: Trouble ordering bigdecimal data within a foreach
                 Key: PIG-4687
                 URL: https://issues.apache.org/jira/browse/PIG-4687
             Project: Pig
          Issue Type: Bug
    Affects Versions: 0.15.0
            Reporter: Luis Guerra


I am having some trouble when ordering bigdecimal data within a foreach. The code I am using is as follows:

{code}
A = group B by (V5, V6, V0, V8, V7);

C = foreach A{
   aux = foreach B generate V3, V4;
   aux = order aux by V3 ASC, V4 ASC;
   generate group.V5, group.V6, group.V0, aux as dd, group.V8 as V8, group.V7 as V7;};
{code}

Being the data B as follows:

B = {V1: chararray, V2: bigdecimal, V3: bigdecimal, V4: bigdecimal, V5: bigdecimal, V6: chararray, V7: bigdecimal, V8: chararray, V9: chararray} 
||V1||V2||V3||V4||V5||V6||V7||V8||V9||
|26004|7|1|20050902|20060902|0000000002|4|1|018210|
|26004|6|1|20040902|20050902|0000000002|3|1|018210|
|26004|5|1|20030902|20040902|0000000002|3|1|018210|
|26004|4|1|20020902|20030902|0000000002|3|1|018210|
|26004|3|1|20010902|20020902|0000000002|3|1|018210|
|26004|2|1|20000902|20010902|0000000002|3|1|018210|
|26004|1|1|19990902|20000902|0000000002|3|1|018210|
|26004|0|1|19980902|19990902|0000000002|3|1|018210|
|26004|17|1|20150902|20160902|0000000002|4|1|018210|
|26004|16|1|20140902|20150902|0000000002|4|1|018210|
|26004|15|1|20130902|20140902|0000000002|4|1|018210|
|26004|14|1|20120902|20130902|0000000002|4|1|018210|
|26004|13|1|20110902|20120902|0000000002|4|1|018210|
|26004|12|1|20100902|20110902|0000000002|4|1|018210|
|26004|11|1|20090902|20100902|0000000002|4|1|018210|
|26004|10|1|20080902|20090902|0000000002|4|1|018210|
|26004|9|1|20070902|20071123|0000000002|4|1|018210|
|26004|8|1|20060902|20070902|0000000002|4|1|018210|
|26004|9|2|20071123|20080902|0000000002|4|1|018210|

And obtaining C as follows:

{code}
(0000000002,3,
{(19980902,19990902),
(19990902,20000902),
(20000902,20010902),
(20010902,20020902),
(20020902,20030902),
(20030902,20040902),
(20040902,20050902)},018210,1)
(0000000002,4,
{(20150902,20160902),
(20050902,20060902),
(20060902,20070902),
(20070902,20071123),
(20071123,20080902),
(20080902,20090902),
(20090902,20100902),
(20100902,20110902),
(20110902,20120902),
(20120902,20130902),
(20130902,20140902),
(20140902,20150902)},018210,1)	
{code}

If I change the data type from bigdecimal to long using a UDF, the order works properly obtaining the result as follows:

{code}
(0000000002,3,
{(19980902,19990902),
(19990902,20000902),
(20000902,20010902),
(20010902,20020902),
(20020902,20030902),
(20030902,20040902),
(20040902,20050902)},018210,)
(0000000002,4,
{(20050902,20060902),
(20060902,20070902),
(20070902,20071123),
(20071123,20080902),
(20080902,20090902),
(20090902,20100902),
(20100902,20110902),
(20110902,20120902),
(20120902,20130902),
(20130902,20140902),
(20140902,20150902),
(20150902,20160902)},018210,)
{code}



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