HuangXingBo commented on a change in pull request #13327:
URL: https://github.com/apache/flink/pull/13327#discussion_r485471276



##########
File path: flink-python/pyflink/datastream/tests/test_data_stream.py
##########
@@ -557,6 +557,44 @@ def assert_chainable(j_stream_graph, 
expected_upstream_chainable,
         # upstream and downstream operators.
         assert_chainable(j_generated_stream_graph, False, False)
 
+    def test_primitive_array_type_info(self):
+        ds = self.env.from_collection([(1, [1.1, 1.2, 1.30]), (2, [2.1, 2.2, 
2.3]),
+                                      (3, [3.1, 3.2, 3.3])],
+                                      type_info=Types.ROW([Types.INT(),
+                                                           
Types.PRIMITIVE_ARRAY(Types.FLOAT())]))
+
+        ds.map(lambda x: x, output_type=Types.ROW([Types.INT(),
+                                                   
Types.PRIMITIVE_ARRAY(Types.FLOAT())]))\
+            .add_sink(self.test_sink)
+        self.env.execute("test array type info")

Review comment:
       ```suggestion
           self.env.execute("test primitive array type info")
   ```

##########
File path: 
flink-python/src/main/java/org/apache/flink/datastream/runtime/typeutils/python/PythonTypeUtils.java
##########
@@ -308,6 +366,14 @@ public static TypeSerializer 
typeInfoSerializerConverter(TypeInformation typeInf
                                                .map(f -> 
typeInfoSerializerConverter(f)).toArray(TypeSerializer[]::new);
                                        return new 
TupleSerializer(Tuple.getTupleClass(tupleTypeInfo.getArity()), 
fieldTypeSerialzers);
                                }
+
+                               if (typeInformation instanceof 
BasicArrayTypeInfo){

Review comment:
       Do we need to add the corresponding test content in 
`testTypeInfotoSerializerConverter`
   

##########
File path: flink-python/pyflink/fn_execution/coders.py
##########
@@ -226,13 +226,24 @@ class ArrayCoder(CollectionCoder):
     """
 
     def __init__(self, elem_coder):
-        self._elem_coder = elem_coder
         super(ArrayCoder, self).__init__(elem_coder)
 
     def get_impl(self):
         return coder_impl.ArrayCoderImpl(self._elem_coder.get_impl())
 
 
+class PrimitiveArrayCoder(CollectionCoder):

Review comment:
       Now that we have introduced `PrimitiveArrayCoder`, can we rename 
`ArrayCoder` to `BasicArrayCoder`
   

##########
File path: flink-python/pyflink/datastream/tests/test_data_stream.py
##########
@@ -557,6 +557,44 @@ def assert_chainable(j_stream_graph, 
expected_upstream_chainable,
         # upstream and downstream operators.
         assert_chainable(j_generated_stream_graph, False, False)
 
+    def test_primitive_array_type_info(self):
+        ds = self.env.from_collection([(1, [1.1, 1.2, 1.30]), (2, [2.1, 2.2, 
2.3]),
+                                      (3, [3.1, 3.2, 3.3])],
+                                      type_info=Types.ROW([Types.INT(),
+                                                           
Types.PRIMITIVE_ARRAY(Types.FLOAT())]))
+
+        ds.map(lambda x: x, output_type=Types.ROW([Types.INT(),
+                                                   
Types.PRIMITIVE_ARRAY(Types.FLOAT())]))\
+            .add_sink(self.test_sink)
+        self.env.execute("test array type info")
+        results = self.test_sink.get_results()
+        expected = ['1,[1.1, 1.2, 1.3]', '2,[2.1, 2.2, 2.3]', '3,[3.1, 3.2, 
3.3]']
+        results.sort()
+        expected.sort()
+        self.assertEqual(expected, results)
+
+    def test_basic_array_type_info(self):
+        ds = self.env.from_collection([(1, [1.1, None, 1.30], [None, 'hi', 
'flink']),
+                                       (2, [None, 2.2, 2.3], ['hello', None, 
'flink']),
+                                      (3, [3.1, 3.2, None], ['hello', 'hi', 
None])],
+                                      type_info=Types.ROW([Types.INT(),
+                                                           
Types.BASIC_ARRAY(Types.FLOAT()),
+                                                           
Types.BASIC_ARRAY(Types.STRING())]))
+
+        ds.map(lambda x: x, output_type=Types.ROW([Types.INT(),
+                                                   
Types.BASIC_ARRAY(Types.FLOAT()),
+                                                   
Types.BASIC_ARRAY(Types.STRING())]))\
+            .add_sink(self.test_sink)
+        self.env.execute("test array type info")

Review comment:
       ```suggestion
           self.env.execute("test basic array type info")
   ```

##########
File path: flink-python/pyflink/datastream/tests/test_data_stream.py
##########
@@ -557,6 +557,44 @@ def assert_chainable(j_stream_graph, 
expected_upstream_chainable,
         # upstream and downstream operators.
         assert_chainable(j_generated_stream_graph, False, False)
 
+    def test_primitive_array_type_info(self):
+        ds = self.env.from_collection([(1, [1.1, 1.2, 1.30]), (2, [2.1, 2.2, 
2.3]),
+                                      (3, [3.1, 3.2, 3.3])],
+                                      type_info=Types.ROW([Types.INT(),
+                                                           
Types.PRIMITIVE_ARRAY(Types.FLOAT())]))
+
+        ds.map(lambda x: x, output_type=Types.ROW([Types.INT(),
+                                                   
Types.PRIMITIVE_ARRAY(Types.FLOAT())]))\
+            .add_sink(self.test_sink)
+        self.env.execute("test array type info")
+        results = self.test_sink.get_results()
+        expected = ['1,[1.1, 1.2, 1.3]', '2,[2.1, 2.2, 2.3]', '3,[3.1, 3.2, 
3.3]']
+        results.sort()
+        expected.sort()
+        self.assertEqual(expected, results)
+
+    def test_basic_array_type_info(self):
+        ds = self.env.from_collection([(1, [1.1, None, 1.30], [None, 'hi', 
'flink']),
+                                       (2, [None, 2.2, 2.3], ['hello', None, 
'flink']),
+                                      (3, [3.1, 3.2, None], ['hello', 'hi', 
None])],
+                                      type_info=Types.ROW([Types.INT(),
+                                                           
Types.BASIC_ARRAY(Types.FLOAT()),
+                                                           
Types.BASIC_ARRAY(Types.STRING())]))
+
+        ds.map(lambda x: x, output_type=Types.ROW([Types.INT(),
+                                                   
Types.BASIC_ARRAY(Types.FLOAT()),
+                                                   
Types.BASIC_ARRAY(Types.STRING())]))\
+            .add_sink(self.test_sink)
+        self.env.execute("test array type info")
+        results = self.test_sink.get_results()
+        expected = ['1,[1.1, null, 1.3],[null, hi, flink]',
+                    '2,[null, 2.2, 2.3],[hello, null, flink]',
+                    '3,[3.1, 3.2, null],[hello, hi, null]']
+        results.sort()
+        expected.sort()
+        print(results)

Review comment:
       remove debugging information




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to