hequn8128 commented on a change in pull request #13061:
URL: https://github.com/apache/flink/pull/13061#discussion_r465435385



##########
File path: flink-python/pyflink/datastream/tests/test_util.py
##########
@@ -0,0 +1,45 @@
+################################################################################
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+# limitations under the License.
+################################################################################
+
+import pickle
+
+from pyflink.java_gateway import get_gateway
+
+
+class DataStreamTestCollectSink(object):

Review comment:
       Refactor the class according to the comments above.

##########
File path: 
flink-python/pyflink/datastream/tests/test_stream_execution_environment.py
##########
@@ -22,9 +22,12 @@
 
 import unittest
 
+

Review comment:
       Please be careful about these unnecessary changes.

##########
File path: 
flink-python/pyflink/datastream/tests/test_stream_execution_environment.py
##########
@@ -211,3 +214,31 @@ def test_execute(self):
         self.assertEqual(len(execution_result.get_all_accumulator_results()), 
0)
         
self.assertIsNone(execution_result.get_accumulator_result('accumulator'))
         self.assertIsNotNone(str(execution_result))
+
+    def test_from_collection_without_data_types(self):
+        ds = self.env.from_collection([(1, 'Hi', 'Hello'), (2, 'Hello', 'Hi')])
+        test_sink = DataStreamTestCollectSink(True)
+        ds._j_data_stream.addSink(test_sink._j_data_stream_test_collect_sink)

Review comment:
       There are some problems with the design:
   1. we need to pass java datastream object explicitly which should be avoided.
   2. we need to specify True false manually. I think we can infer the true 
false from the input datastream, i.e., set true when output_type is 
`PickledBytesTypeInfo`.
   
   The code may looks like:
   ```
   collect_util = DataStreamCollectUtil()
   collect_util.collect(ds)
   results = collect_util.results()
   ```

##########
File path: flink-python/pyflink/datastream/data_stream.py
##########
@@ -0,0 +1,162 @@
+################################################################################
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+# limitations under the License.
+################################################################################
+from pyflink.common import typeinfo, ExecutionConfig
+from pyflink.common.typeinfo import TypeInformation
+
+
+class DataStream(object):
+    """
+    A DataStream represents a stream of elements of the same type. A 
DataStream can be transformed
+    into another DataStream by applying a transformation as for example:
+    ::
+        >>> DataStream.map(MapFunctionImpl())
+        >>> DataStream.filter(FilterFunctionImpl())
+    """
+
+    def __init__(self, j_data_stream):
+        self._j_data_stream = j_data_stream
+
+    def get_name(self) -> str:
+        """
+        Gets the name of the current data stream. This name is used by the 
visualization and logging
+        during runtime.
+
+        :return: Name of the stream.
+        """
+        return self._j_data_stream.getName()
+
+    def name(self, name: str):

Review comment:
       Should also add tests to verify these methods.




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