[
https://issues.apache.org/jira/browse/PIG-4687?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14973808#comment-14973808
]
Daniel Dai commented on PIG-4687:
---------------------------------
The script posted apparently will not produce the result you mentioned. I
assume your script should be:
{code}
B = load 'input' as (V1: chararray, V2: bigdecimal, V3: bigdecimal, V4:
bigdecimal, V5: bigdecimal, V6: chararray, V7: bigdecimal, V8: chararray, V9:
chararray);
A = group B by (V6, V7, V9, V8);
C = foreach A{
aux = foreach B generate V4, V5;
aux = order aux by V4 ASC, V5 ASC;
generate group.V6, group.V7, aux as dd, group.V9 as V9, group.V8 as V8;};
dump C;
{code}
However, I cannot see the wrong result you mentioned, here is what I get:
{code}
(0000000002,3,{(19980902,19990902),(19990902,20000902),(20000902,20010902),(20010902,20020902),(20020902,20030902),(20030902,20040902),(20040902,20050902)},018210,1)
(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,1)
{code}
> 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)