Author: rohini
Date: Wed Sep  2 21:47:20 2015
New Revision: 1700908

URL: http://svn.apache.org/r1700908
Log:
Fix test failure from PIG-4627: [Pig on Tez] Self join does not handle null 
values correctly

Modified:
    
pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/PigBytesRawComparator.java

Modified: 
pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/PigBytesRawComparator.java
URL: 
http://svn.apache.org/viewvc/pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/PigBytesRawComparator.java?rev=1700908&r1=1700907&r2=1700908&view=diff
==============================================================================
--- 
pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/PigBytesRawComparator.java
 (original)
+++ 
pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/mapReduceLayer/PigBytesRawComparator.java
 Wed Sep  2 21:47:20 2015
@@ -124,14 +124,20 @@ public class PigBytesRawComparator exten
             if( dataByteArraysCompare ) {
               rc = WritableComparator.compareBytes(b1, offset1, length1, b2, 
offset2, length2);
             } else {
-              // Subtract 2, one for null byte and one for index byte. Also, 
do not reverse the sign
-              // of rc when mAsc[0] is false because 
BinInterSedesTupleRawComparator.compare() already
-              // takes that into account.
+              // Subtract 2, one for null byte and one for index byte.
               rc = mWrappedComp.compare(b1, s1 + 1, l1 - 2, b2, s2 + 1, l2 - 
2);
               // handle PIG-927. If tuples are equal but any field inside 
tuple is null,
               // then we do not merge keys if indices are not same
-              if (rc == 0 && mWrappedComp.hasComparedTupleNull())
-                  rc = b1[s1 + 1] - b2[s2 + 1];
+              if (rc == 0 && mWrappedComp.hasComparedTupleNull()) {
+                rc = b1[s1 + 1] - b2[s2 + 1];
+                // Redundant as there will not be any sort order with multiple 
indices
+                // But just for sake of completeness.
+                if (!mAsc[0]) rc *= -1;
+              }
+              // PIG-4298 - Return here to avoid reversing the sign of rc when
+              // mAsc[0] is false because 
BinInterSedesTupleRawComparator.compare()
+              // already takes that into account.
+              return rc;
             }
         } else {
             // Two nulls are equal if indices are same


Reply via email to