You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pig.apache.org by da...@apache.org on 2014/10/16 06:26:45 UTC

svn commit: r1632205 - /pig/branches/branch-0.14/src/python/streaming/controller.py

Author: daijy
Date: Thu Oct 16 04:26:45 2014
New Revision: 1632205

URL: http://svn.apache.org/r1632205
Log:
PIG-4227: Streaming Python UDF handles bag outputs incorrectly (PIG-4227-2.patch)

Modified:
    pig/branches/branch-0.14/src/python/streaming/controller.py

Modified: pig/branches/branch-0.14/src/python/streaming/controller.py
URL: http://svn.apache.org/viewvc/pig/branches/branch-0.14/src/python/streaming/controller.py?rev=1632205&r1=1632204&r2=1632205&view=diff
==============================================================================
--- pig/branches/branch-0.14/src/python/streaming/controller.py (original)
+++ pig/branches/branch-0.14/src/python/streaming/controller.py Thu Oct 16 04:26:45 2014
@@ -297,6 +297,12 @@ def _deserialize_collection(input_str, r
     else:
         return list_result
 
+def wrap_tuple(o, serialized_item):
+    if type(o) != tuple:
+        return WRAPPED_TUPLE_START + serialized_item + WRAPPED_TUPLE_END
+    else:
+        return serialized_item
+
 def serialize_output(output, utfEncodeAllFields=False):
     """
     @param utfEncodeStrings - Generally we want to utf encode only strings.  But for
@@ -314,7 +320,7 @@ def serialize_output(output, utfEncodeAl
                 WRAPPED_TUPLE_END)
     elif output_type == list:
         return (WRAPPED_BAG_START +
-                WRAPPED_FIELD_DELIMITER.join([(WRAPPED_TUPLE_START + serialize_output(o, utfEncodeAllFields) + WRAPPED_TUPLE_END) for o in output]) +
+                WRAPPED_FIELD_DELIMITER.join([wrap_tuple(o, serialize_output(o, utfEncodeAllFields)) for o in output]) +
                 WRAPPED_BAG_END)
     elif output_type == dict:
         return (WRAPPED_MAP_START +