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/09 15:57:40 UTC

[GitHub] [flink] shuiqiangchen opened a new pull request #13094: [FLINK-18766][python] Support add_sink() for Python DataStream API.

shuiqiangchen opened a new pull request #13094:
URL: https://github.com/apache/flink/pull/13094


   <!--
   *Thank you very much for contributing to Apache Flink - we are happy that you want to help us improve Flink. To help the community review your contribution in the best possible way, please go through the checklist below, which will get the contribution into a shape in which it can be best reviewed.*
   
   *Please understand that we do not do this to make contributions to Flink a hassle. In order to uphold a high standard of quality for code contributions, while at the same time managing a large number of contributions, we need contributors to prepare the contributions well, and give reviewers enough contextual information for the review. Please also understand that contributions that do not follow this guide will take longer to review and thus typically be picked up with lower priority by the community.*
   
   ## Contribution Checklist
   
     - Make sure that the pull request corresponds to a [JIRA issue](https://issues.apache.org/jira/projects/FLINK/issues). Exceptions are made for typos in JavaDoc or documentation files, which need no JIRA issue.
     
     - Name the pull request in the form "[FLINK-XXXX] [component] Title of the pull request", where *FLINK-XXXX* should be replaced by the actual issue number. Skip *component* if you are unsure about which is the best component.
     Typo fixes that have no associated JIRA issue should be named following this pattern: `[hotfix] [docs] Fix typo in event time introduction` or `[hotfix] [javadocs] Expand JavaDoc for PuncuatedWatermarkGenerator`.
   
     - Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
     
     - Make sure that the change passes the automated tests, i.e., `mvn clean verify` passes. You can set up Azure Pipelines CI to do that following [this guide](https://cwiki.apache.org/confluence/display/FLINK/Azure+Pipelines#AzurePipelines-Tutorial:SettingupAzurePipelinesforaforkoftheFlinkrepository).
   
     - Each pull request should address only one issue, not mix up code from multiple issues.
     
     - Each commit in the pull request has a meaningful commit message (including the JIRA id)
   
     - Once all items of the checklist are addressed, remove the above text and this checklist, leaving only the filled out template below.
   
   
   **(The sections below can be removed for hotfixes of typos)**
   -->
   
   ## What is the purpose of the change
   
   Support add_sink() for Python DataStream API.
   
   ## Brief change log
   
    - Add a new module named connectors which includes all source/sink related classes.
    - Add add_sink() interface for DataStream API.
   
   ## Verifying this change
   
   This change currently have no test case coverage.
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): ( no)
     - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: ( no)
     - The serializers: (no)
     - The runtime per-record code paths (performance sensitive): (no)
     - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn/Mesos, ZooKeeper: (no)
     - The S3 file system connector: (no)
   
   ## Documentation
   
     - Does this pull request introduce a new feature? (no)
     - If yes, how is the feature documented? ( not documented)
   


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



[GitHub] [flink] flinkbot commented on pull request #13094: [FLINK-18766][python] Support add_sink() for Python DataStream API.

Posted by GitBox <gi...@apache.org>.
flinkbot commented on pull request #13094:
URL: https://github.com/apache/flink/pull/13094#issuecomment-671071159


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "a8517591f8e26a91f25c00e2532af495b8fd3c7b",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "a8517591f8e26a91f25c00e2532af495b8fd3c7b",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * a8517591f8e26a91f25c00e2532af495b8fd3c7b UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


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



[GitHub] [flink] flinkbot edited a comment on pull request #13094: [FLINK-18766][python] Support add_sink() for Python DataStream API.

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13094:
URL: https://github.com/apache/flink/pull/13094#issuecomment-671071159


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "a8517591f8e26a91f25c00e2532af495b8fd3c7b",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=5318",
       "triggerID" : "a8517591f8e26a91f25c00e2532af495b8fd3c7b",
       "triggerType" : "PUSH"
     }, {
       "hash" : "b2d512352be69a3661708014f21f0dad16050c10",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "b2d512352be69a3661708014f21f0dad16050c10",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * a8517591f8e26a91f25c00e2532af495b8fd3c7b Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=5318) 
   * b2d512352be69a3661708014f21f0dad16050c10 UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


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



[GitHub] [flink] hequn8128 commented on a change in pull request #13094: [FLINK-18766][python] Support add_sink() for Python DataStream API.

Posted by GitBox <gi...@apache.org>.
hequn8128 commented on a change in pull request #13094:
URL: https://github.com/apache/flink/pull/13094#discussion_r467659675



##########
File path: flink-python/pyflink/datastream/connectors.py
##########
@@ -0,0 +1,37 @@
+################################################################################
+#  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.
+################################################################################
+
+
+class SinkFunction(object):

Review comment:
       Could we also add tests for SinkFunction. For example, you can add a CustomSinkFunction which extends SinkFunction. The code looks like:
   ```
   class TestSinkFunction(SinkFunction):
      def __init__(self, func):
         ...
      def get_results():
        ...
   ```




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



[GitHub] [flink] flinkbot edited a comment on pull request #13094: [FLINK-18766][python] Support add_sink() for Python DataStream API.

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13094:
URL: https://github.com/apache/flink/pull/13094#issuecomment-671071159


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "a8517591f8e26a91f25c00e2532af495b8fd3c7b",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=5318",
       "triggerID" : "a8517591f8e26a91f25c00e2532af495b8fd3c7b",
       "triggerType" : "PUSH"
     }, {
       "hash" : "b2d512352be69a3661708014f21f0dad16050c10",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=5329",
       "triggerID" : "b2d512352be69a3661708014f21f0dad16050c10",
       "triggerType" : "PUSH"
     }, {
       "hash" : "ec8d9a8dc42c92427dbb9c51b69be9eaae4cd889",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=5335",
       "triggerID" : "ec8d9a8dc42c92427dbb9c51b69be9eaae4cd889",
       "triggerType" : "PUSH"
     }, {
       "hash" : "ee75e6cf97ecb11fcff6f48251f0804a6d04c7d4",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "ee75e6cf97ecb11fcff6f48251f0804a6d04c7d4",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * b2d512352be69a3661708014f21f0dad16050c10 Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=5329) 
   * ec8d9a8dc42c92427dbb9c51b69be9eaae4cd889 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=5335) 
   * ee75e6cf97ecb11fcff6f48251f0804a6d04c7d4 UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


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



[GitHub] [flink] flinkbot edited a comment on pull request #13094: [FLINK-18766][python] Support add_sink() for Python DataStream API.

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13094:
URL: https://github.com/apache/flink/pull/13094#issuecomment-671071159


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "a8517591f8e26a91f25c00e2532af495b8fd3c7b",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=5318",
       "triggerID" : "a8517591f8e26a91f25c00e2532af495b8fd3c7b",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * a8517591f8e26a91f25c00e2532af495b8fd3c7b Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=5318) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


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



[GitHub] [flink] hequn8128 commented on a change in pull request #13094: [FLINK-18766][python] Support add_sink() for Python DataStream API.

Posted by GitBox <gi...@apache.org>.
hequn8128 commented on a change in pull request #13094:
URL: https://github.com/apache/flink/pull/13094#discussion_r467670697



##########
File path: flink-python/pyflink/datastream/connectors.py
##########
@@ -0,0 +1,37 @@
+################################################################################
+#  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.
+################################################################################
+
+
+class SinkFunction(object):

Review comment:
       It's better to add the SinkFunction in the functions.py

##########
File path: flink-python/pyflink/datastream/connectors.py
##########
@@ -0,0 +1,37 @@
+################################################################################
+#  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.
+################################################################################
+
+
+class SinkFunction(object):
+    """
+    The base class for SinkFunctions.
+    """
+
+    def __init__(self, j_sink_func):

Review comment:
       It makes no sense to let Python users init SinkFunction with a Java object. I think we can make the SinkFunction extends FunctionWrapper and add a `get_java_function()` method in `FunctionWrapper`.
   Meanwhile, the SinkFunction should support initialization with a java string class.  

##########
File path: flink-python/pyflink/datastream/connectors.py
##########
@@ -0,0 +1,37 @@
+################################################################################
+#  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.
+################################################################################
+
+
+class SinkFunction(object):

Review comment:
       Could we also add tests for SinkFunction.




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



[GitHub] [flink] flinkbot edited a comment on pull request #13094: [FLINK-18766][python] Support add_sink() for Python DataStream API.

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13094:
URL: https://github.com/apache/flink/pull/13094#issuecomment-671071159


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "a8517591f8e26a91f25c00e2532af495b8fd3c7b",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=5318",
       "triggerID" : "a8517591f8e26a91f25c00e2532af495b8fd3c7b",
       "triggerType" : "PUSH"
     }, {
       "hash" : "b2d512352be69a3661708014f21f0dad16050c10",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=5329",
       "triggerID" : "b2d512352be69a3661708014f21f0dad16050c10",
       "triggerType" : "PUSH"
     }, {
       "hash" : "ec8d9a8dc42c92427dbb9c51b69be9eaae4cd889",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=5335",
       "triggerID" : "ec8d9a8dc42c92427dbb9c51b69be9eaae4cd889",
       "triggerType" : "PUSH"
     }, {
       "hash" : "ee75e6cf97ecb11fcff6f48251f0804a6d04c7d4",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=5339",
       "triggerID" : "ee75e6cf97ecb11fcff6f48251f0804a6d04c7d4",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * ec8d9a8dc42c92427dbb9c51b69be9eaae4cd889 Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=5335) 
   * ee75e6cf97ecb11fcff6f48251f0804a6d04c7d4 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=5339) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


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



[GitHub] [flink] shuiqiangchen commented on a change in pull request #13094: [FLINK-18766][python] Support add_sink() for Python DataStream API.

Posted by GitBox <gi...@apache.org>.
shuiqiangchen commented on a change in pull request #13094:
URL: https://github.com/apache/flink/pull/13094#discussion_r467729190



##########
File path: flink-python/pyflink/datastream/tests/test_stream_execution_environment.py
##########
@@ -216,7 +216,7 @@ def test_execute(self):
 
     def test_from_collection_without_data_types(self):
         ds = self.env.from_collection([(1, 'Hi', 'Hello'), (2, 'Hello', 'Hi')])
-        collect_util = DataStreamCollectUtil()
+        collect_util = DataStreamTestSinkFunction()

Review comment:
       Sorry, I forget to update this part.




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



[GitHub] [flink] flinkbot edited a comment on pull request #13094: [FLINK-18766][python] Support add_sink() for Python DataStream API.

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13094:
URL: https://github.com/apache/flink/pull/13094#issuecomment-671071159


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "a8517591f8e26a91f25c00e2532af495b8fd3c7b",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=5318",
       "triggerID" : "a8517591f8e26a91f25c00e2532af495b8fd3c7b",
       "triggerType" : "PUSH"
     }, {
       "hash" : "b2d512352be69a3661708014f21f0dad16050c10",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=5329",
       "triggerID" : "b2d512352be69a3661708014f21f0dad16050c10",
       "triggerType" : "PUSH"
     }, {
       "hash" : "ec8d9a8dc42c92427dbb9c51b69be9eaae4cd889",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=5335",
       "triggerID" : "ec8d9a8dc42c92427dbb9c51b69be9eaae4cd889",
       "triggerType" : "PUSH"
     }, {
       "hash" : "ee75e6cf97ecb11fcff6f48251f0804a6d04c7d4",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "ee75e6cf97ecb11fcff6f48251f0804a6d04c7d4",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * ec8d9a8dc42c92427dbb9c51b69be9eaae4cd889 Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=5335) 
   * ee75e6cf97ecb11fcff6f48251f0804a6d04c7d4 UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


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



[GitHub] [flink] flinkbot edited a comment on pull request #13094: [FLINK-18766][python] Support add_sink() for Python DataStream API.

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13094:
URL: https://github.com/apache/flink/pull/13094#issuecomment-671071159


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "a8517591f8e26a91f25c00e2532af495b8fd3c7b",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=5318",
       "triggerID" : "a8517591f8e26a91f25c00e2532af495b8fd3c7b",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * a8517591f8e26a91f25c00e2532af495b8fd3c7b Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=5318) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


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



[GitHub] [flink] hequn8128 commented on a change in pull request #13094: [FLINK-18766][python] Support add_sink() for Python DataStream API.

Posted by GitBox <gi...@apache.org>.
hequn8128 commented on a change in pull request #13094:
URL: https://github.com/apache/flink/pull/13094#discussion_r467659569



##########
File path: flink-python/pyflink/datastream/connectors.py
##########
@@ -0,0 +1,37 @@
+################################################################################
+#  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.
+################################################################################
+
+
+class SinkFunction(object):
+    """
+    The base class for SinkFunctions.
+    """
+
+    def __init__(self, j_sink_func):

Review comment:
       It makes no sense to let Python users init SinkFunction with a Java object. I think we can make the SinkFunction extends JavaFunctionWrapper and add a `get_java_function()` method in `FunctionWrapper`.
   Meanwhile, the SinkFunction should support initialization with a java string class.  




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



[GitHub] [flink] flinkbot edited a comment on pull request #13094: [FLINK-18766][python] Support add_sink() for Python DataStream API.

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13094:
URL: https://github.com/apache/flink/pull/13094#issuecomment-671071159


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "a8517591f8e26a91f25c00e2532af495b8fd3c7b",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=5318",
       "triggerID" : "a8517591f8e26a91f25c00e2532af495b8fd3c7b",
       "triggerType" : "PUSH"
     }, {
       "hash" : "b2d512352be69a3661708014f21f0dad16050c10",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=5329",
       "triggerID" : "b2d512352be69a3661708014f21f0dad16050c10",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * a8517591f8e26a91f25c00e2532af495b8fd3c7b Azure: [SUCCESS](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=5318) 
   * b2d512352be69a3661708014f21f0dad16050c10 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=5329) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


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



[GitHub] [flink] flinkbot commented on pull request #13094: [FLINK-18766][python] Support add_sink() for Python DataStream API.

Posted by GitBox <gi...@apache.org>.
flinkbot commented on pull request #13094:
URL: https://github.com/apache/flink/pull/13094#issuecomment-671069233


   Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community
   to review your pull request. We will use this comment to track the progress of the review.
   
   
   ## Automated Checks
   Last check on commit a8517591f8e26a91f25c00e2532af495b8fd3c7b (Sun Aug 09 16:00:27 UTC 2020)
   
   **Warnings:**
    * No documentation files were touched! Remember to keep the Flink docs up to date!
    * **This pull request references an unassigned [Jira ticket](https://issues.apache.org/jira/browse/FLINK-18766).** According to the [code contribution guide](https://flink.apache.org/contributing/contribute-code.html), tickets need to be assigned before starting with the implementation work.
   
   
   <sub>Mention the bot in a comment to re-run the automated checks.</sub>
   ## Review Progress
   
   * ❓ 1. The [description] looks good.
   * ❓ 2. There is [consensus] that the contribution should go into to Flink.
   * ❓ 3. Needs [attention] from.
   * ❓ 4. The change fits into the overall [architecture].
   * ❓ 5. Overall code [quality] is good.
   
   Please see the [Pull Request Review Guide](https://flink.apache.org/contributing/reviewing-prs.html) for a full explanation of the review process.<details>
    The Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot approve description` to approve one or more aspects (aspects: `description`, `consensus`, `architecture` and `quality`)
    - `@flinkbot approve all` to approve all aspects
    - `@flinkbot approve-until architecture` to approve everything until `architecture`
    - `@flinkbot attention @username1 [@username2 ..]` to require somebody's attention
    - `@flinkbot disapprove architecture` to remove an approval you gave earlier
   </details>


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



[GitHub] [flink] hequn8128 commented on a change in pull request #13094: [FLINK-18766][python] Support add_sink() for Python DataStream API.

Posted by GitBox <gi...@apache.org>.
hequn8128 commented on a change in pull request #13094:
URL: https://github.com/apache/flink/pull/13094#discussion_r467727394



##########
File path: flink-python/pyflink/datastream/tests/test_stream_execution_environment.py
##########
@@ -216,7 +216,7 @@ def test_execute(self):
 
     def test_from_collection_without_data_types(self):
         ds = self.env.from_collection([(1, 'Hi', 'Hello'), (2, 'Hello', 'Hi')])
-        collect_util = DataStreamCollectUtil()
+        collect_util = DataStreamTestSinkFunction()

Review comment:
       The test would fail, i.e., there is no `collect` method on `collect_util`.




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



[GitHub] [flink] hequn8128 commented on a change in pull request #13094: [FLINK-18766][python] Support add_sink() for Python DataStream API.

Posted by GitBox <gi...@apache.org>.
hequn8128 commented on a change in pull request #13094:
URL: https://github.com/apache/flink/pull/13094#discussion_r467693696



##########
File path: flink-python/pyflink/datastream/tests/test_data_stream.py
##########
@@ -149,6 +149,22 @@ def flat_map(value):
         expected.sort()
         self.assertEqual(expected, results)
 
+    def test_add_sink_with_sink_func_class(self):

Review comment:
       The test is useless here, as it uses the DataStreamCollectUtil to collect and verify. The `add_sink` has not been tested. You can add a CustomSinkFunction which extends SinkFunction. The code looks like:
   ```
   class TestSinkFunction(SinkFunction):
      def __init__(self, func):
         ...
      def get_results():
        ...
   ```

##########
File path: flink-python/pyflink/datastream/functions.py
##########
@@ -147,3 +150,34 @@ def _get_python_env():
     gateway = get_gateway()
     exec_type = gateway.jvm.org.apache.flink.table.functions.python.PythonEnv.ExecType.PROCESS
     return gateway.jvm.org.apache.flink.table.functions.python.PythonEnv(exec_type)
+
+
+class JavaFunctionWrapper(object):

Review comment:
       Add comments for this class.

##########
File path: flink-python/pyflink/datastream/functions.py
##########
@@ -147,3 +150,34 @@ def _get_python_env():
     gateway = get_gateway()
     exec_type = gateway.jvm.org.apache.flink.table.functions.python.PythonEnv.ExecType.PROCESS
     return gateway.jvm.org.apache.flink.table.functions.python.PythonEnv(exec_type)
+
+
+class JavaFunctionWrapper(object):
+
+    def __init__(self, j_function):
+        self._j_function = j_function
+
+    def get_java_function(self):
+        return self._j_function
+
+
+class SinkFunction(JavaFunctionWrapper):
+    """
+    The base class for SinkFunctions.
+    """
+
+    def __init__(self, sink_func: Union[str, JavaObject], *args):
+        """
+        Constructor of SinkFunction.
+
+        :param sink_func: The java SinkFunction object.
+        """
+        if isinstance(sink_func, str):
+            j_source_func_class = get_gateway().jvm.__getattr__(sink_func)
+            if len(args) > 0:
+                j_sink_func = j_source_func_class(*args)
+            else:
+                j_sink_func = j_source_func_class()
+        else:
+            j_sink_func = sink_func
+        super(SinkFunction, self).__init__(j_sink_func)

Review comment:
       Move this logic into `JavaFunctionWrapper` so that can be shared by other classes, e.g., SourceFunction. 

##########
File path: flink-python/pyflink/datastream/functions.py
##########
@@ -147,3 +150,34 @@ def _get_python_env():
     gateway = get_gateway()
     exec_type = gateway.jvm.org.apache.flink.table.functions.python.PythonEnv.ExecType.PROCESS
     return gateway.jvm.org.apache.flink.table.functions.python.PythonEnv(exec_type)
+
+
+class JavaFunctionWrapper(object):
+
+    def __init__(self, j_function):
+        self._j_function = j_function
+
+    def get_java_function(self):
+        return self._j_function
+
+
+class SinkFunction(JavaFunctionWrapper):
+    """
+    The base class for SinkFunctions.
+    """
+
+    def __init__(self, sink_func: Union[str, JavaObject], *args):

Review comment:
       If you want to support `*args`, you need to take all types into consideration, i.e., convert different python types to java types. I think we don't need to support `*args` here. 




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



[GitHub] [flink] flinkbot edited a comment on pull request #13094: [FLINK-18766][python] Support add_sink() for Python DataStream API.

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13094:
URL: https://github.com/apache/flink/pull/13094#issuecomment-671071159


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "a8517591f8e26a91f25c00e2532af495b8fd3c7b",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=5318",
       "triggerID" : "a8517591f8e26a91f25c00e2532af495b8fd3c7b",
       "triggerType" : "PUSH"
     }, {
       "hash" : "b2d512352be69a3661708014f21f0dad16050c10",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=5329",
       "triggerID" : "b2d512352be69a3661708014f21f0dad16050c10",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * b2d512352be69a3661708014f21f0dad16050c10 Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=5329) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


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



[GitHub] [flink] hequn8128 commented on a change in pull request #13094: [FLINK-18766][python] Support add_sink() for Python DataStream API.

Posted by GitBox <gi...@apache.org>.
hequn8128 commented on a change in pull request #13094:
URL: https://github.com/apache/flink/pull/13094#discussion_r467659569



##########
File path: flink-python/pyflink/datastream/connectors.py
##########
@@ -0,0 +1,37 @@
+################################################################################
+#  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.
+################################################################################
+
+
+class SinkFunction(object):
+    """
+    The base class for SinkFunctions.
+    """
+
+    def __init__(self, j_sink_func):

Review comment:
       It makes no sense to let Python users init SinkFunction with a Java object. I think we can make the SinkFunction extends JavaFunctionWrapper and add a `get_java_function()` method in `JavaFunctionWrapper`.
   Meanwhile, the `JavaFunctionWrapper` should support initialization both with a java string or a java object.  




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



[GitHub] [flink] flinkbot edited a comment on pull request #13094: [FLINK-18766][python] Support add_sink() for Python DataStream API.

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13094:
URL: https://github.com/apache/flink/pull/13094#issuecomment-671071159


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "a8517591f8e26a91f25c00e2532af495b8fd3c7b",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=5318",
       "triggerID" : "a8517591f8e26a91f25c00e2532af495b8fd3c7b",
       "triggerType" : "PUSH"
     }, {
       "hash" : "b2d512352be69a3661708014f21f0dad16050c10",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=5329",
       "triggerID" : "b2d512352be69a3661708014f21f0dad16050c10",
       "triggerType" : "PUSH"
     }, {
       "hash" : "ec8d9a8dc42c92427dbb9c51b69be9eaae4cd889",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "ec8d9a8dc42c92427dbb9c51b69be9eaae4cd889",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * b2d512352be69a3661708014f21f0dad16050c10 Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=5329) 
   * ec8d9a8dc42c92427dbb9c51b69be9eaae4cd889 UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


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



[GitHub] [flink] flinkbot edited a comment on pull request #13094: [FLINK-18766][python] Support add_sink() for Python DataStream API.

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on pull request #13094:
URL: https://github.com/apache/flink/pull/13094#issuecomment-671071159


   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "a8517591f8e26a91f25c00e2532af495b8fd3c7b",
       "status" : "DELETED",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=5318",
       "triggerID" : "a8517591f8e26a91f25c00e2532af495b8fd3c7b",
       "triggerType" : "PUSH"
     }, {
       "hash" : "b2d512352be69a3661708014f21f0dad16050c10",
       "status" : "FAILURE",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=5329",
       "triggerID" : "b2d512352be69a3661708014f21f0dad16050c10",
       "triggerType" : "PUSH"
     }, {
       "hash" : "ec8d9a8dc42c92427dbb9c51b69be9eaae4cd889",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=5335",
       "triggerID" : "ec8d9a8dc42c92427dbb9c51b69be9eaae4cd889",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * b2d512352be69a3661708014f21f0dad16050c10 Azure: [FAILURE](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=5329) 
   * ec8d9a8dc42c92427dbb9c51b69be9eaae4cd889 Azure: [PENDING](https://dev.azure.com/apache-flink/98463496-1af2-4620-8eab-a2ecc1a2e6fe/_build/results?buildId=5335) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>


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



[GitHub] [flink] hequn8128 merged pull request #13094: [FLINK-18766][python] Support add_sink() for Python DataStream API.

Posted by GitBox <gi...@apache.org>.
hequn8128 merged pull request #13094:
URL: https://github.com/apache/flink/pull/13094


   


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