You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2020/08/05 03:25:52 UTC

[GitHub] [flink] shuiqiangchen commented on a change in pull request #13061: [FLINK-18764][python] Add DataStream class and support from_collectio…

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



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

Review comment:
       Thank you, I will pay more attention to it.

##########
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:
       Yes, there might be some spaces for improvements.

##########
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:
       Ok, I will do it.

##########
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:
       Yes, I will add the corresponding tests to verify them.




----------------------------------------------------------------
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:
users@infra.apache.org