pig-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cheol...@apache.org
Subject svn commit: r1707576 - in /pig/trunk: CHANGES.txt src/org/apache/pig/impl/streaming/PigStreamingUDF.java test/org/apache/pig/impl/streaming/TestPigStreamingUDF.java
Date Thu, 08 Oct 2015 16:09:17 GMT
Author: cheolsoo
Date: Thu Oct  8 16:09:15 2015
New Revision: 1707576

URL: http://svn.apache.org/viewvc?rev=1707576&view=rev
Log:
PIG-4696: Empty map returned by a streaming_python udf wrongly contains a null key (cheolsoo)

Modified:
    pig/trunk/CHANGES.txt
    pig/trunk/src/org/apache/pig/impl/streaming/PigStreamingUDF.java
    pig/trunk/test/org/apache/pig/impl/streaming/TestPigStreamingUDF.java

Modified: pig/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/pig/trunk/CHANGES.txt?rev=1707576&r1=1707575&r2=1707576&view=diff
==============================================================================
--- pig/trunk/CHANGES.txt (original)
+++ pig/trunk/CHANGES.txt Thu Oct  8 16:09:15 2015
@@ -49,6 +49,8 @@ PIG-4639: Add better parser for Apache H
 
 BUG FIXES
 
+PIG-4696: Empty map returned by a streaming_python udf wrongly contains a null key (cheolsoo)
+
 PIG-4691: [Pig on Tez] Support for whitelisting storefuncs for union optimization (rohini)
 
 PIG-3957: Refactor out resetting input key in TezDagBuilder (rohini)

Modified: pig/trunk/src/org/apache/pig/impl/streaming/PigStreamingUDF.java
URL: http://svn.apache.org/viewvc/pig/trunk/src/org/apache/pig/impl/streaming/PigStreamingUDF.java?rev=1707576&r1=1707575&r2=1707576&view=diff
==============================================================================
--- pig/trunk/src/org/apache/pig/impl/streaming/PigStreamingUDF.java (original)
+++ pig/trunk/src/org/apache/pig/impl/streaming/PigStreamingUDF.java Thu Oct  8 16:09:15 2015
@@ -202,7 +202,7 @@ public class PigStreamingUDF extends Pig
 
             if (StreamingDelimiters.isDelimiter(DELIMS.getFieldDelim(), buf, index, depth,
endIndex)) {
                 val = extractString(buf, fieldStart, index - 1, true);
-                map.put(key, val);
+                if (key != null) map.put(key, val);
                 fieldStart = index + 3;
             }
         }

Modified: pig/trunk/test/org/apache/pig/impl/streaming/TestPigStreamingUDF.java
URL: http://svn.apache.org/viewvc/pig/trunk/test/org/apache/pig/impl/streaming/TestPigStreamingUDF.java?rev=1707576&r1=1707575&r2=1707576&view=diff
==============================================================================
--- pig/trunk/test/org/apache/pig/impl/streaming/TestPigStreamingUDF.java (original)
+++ pig/trunk/test/org/apache/pig/impl/streaming/TestPigStreamingUDF.java Thu Oct  8 16:09:15
2015
@@ -369,6 +369,18 @@ public class TestPigStreamingUDF {
     }
     
     @Test
+    public void testDeserialize__emptyMap() throws IOException {
+        byte[] input = "|[_|]_|_".getBytes();
+        FieldSchema fs = new FieldSchema("", DataType.MAP);
+        PigStreamingUDF sp = new PigStreamingUDF(fs);
+
+        Map<String, String> expectedOutput = new TreeMap<String, String>();
+
+        Object out = sp.deserialize(input, 0, input.length);
+        Assert.assertEquals(tf.newTuple(expectedOutput), out);
+    }
+
+    @Test
     public void testDeserialize__bug() throws Exception {
         byte[] input = "|(_|-_|,_32|,_987654321098765432|,_987654321098765432|)_|_".getBytes();
 



Mime
View raw message