dianfu commented on code in PR #22190:
URL: https://github.com/apache/flink/pull/22190#discussion_r1138232483


##########
flink-python/pyflink/datastream/utils.py:
##########
@@ -57,68 +57,63 @@ def convert_to_python_obj(data, type_info):
         return convert_to_python_obj(data, type_info._type_info)
     else:
         gateway = get_gateway()
-        pickle_bytes = gateway.jvm.PythonBridgeUtils. \
+        pickled_bytes = gateway.jvm.PythonBridgeUtils. \
             getPickledBytesFromJavaObject(data, type_info.get_java_type_info())
-        if isinstance(type_info, RowTypeInfo) or isinstance(type_info, 
TupleTypeInfo):
-            if isinstance(type_info, RowTypeInfo):
-                field_data = zip(list(pickle_bytes[1:]), 
type_info.get_field_types())
-            else:
-                field_data = zip(pickle_bytes, type_info.get_field_types())
-            fields = []
-            for data, field_type in field_data:
-                if len(data) == 0:
-                    fields.append(None)
-                else:
-                    fields.append(pickled_bytes_to_python_converter(data, 
field_type))
-            if isinstance(type_info, RowTypeInfo):
-                return Row.of_kind(RowKind(int.from_bytes(pickle_bytes[0], 
'little')), *fields)
-            else:
-                return tuple(fields)
-        else:
-            return pickled_bytes_to_python_converter(pickle_bytes, type_info)
+        return pickled_bytes_to_python_obj(pickled_bytes, type_info)
 
 
-def pickled_bytes_to_python_converter(data, field_type):
-    if isinstance(field_type, RowTypeInfo):
+def pickled_bytes_to_python_obj(data, type_info):
+    if isinstance(type_info, RowTypeInfo):
         row_kind = RowKind(int.from_bytes(data[0], 'little'))
-        data = zip(list(data[1:]), field_type.get_field_types())
+        field_data_with_types = zip(list(data[1:]), 
type_info.get_field_types())
         fields = []
-        for d, d_type in data:
-            fields.append(pickled_bytes_to_python_converter(d, d_type))
-        row = Row.of_kind(row_kind, *fields)
-        return row
+        for field_data, field_type in field_data_with_types:
+            if len(data) == 0:

Review Comment:
   Good catch!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to