You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by GitBox <gi...@apache.org> on 2022/09/22 08:45:29 UTC

[GitHub] [incubator-seatunnel] liugddx opened a new pull request, #2844: [Feature][Connector-v2] improve assert sink connector

liugddx opened a new pull request, #2844:
URL: https://github.com/apache/incubator-seatunnel/pull/2844

   Close #2796
   
   <!--
   
   Thank you for contributing to SeaTunnel! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   ## Contribution Checklist
   
     - Make sure that the pull request corresponds to a [GITHUB issue](https://github.com/apache/incubator-seatunnel/issues).
   
     - Name the pull request in the form "[Feature] [component] Title of the pull request", where *Feature* can be replaced by `Hotfix`, `Bug`, etc.
   
     - Minor fixes should be named following this pattern: `[hotfix] [docs] Fix typo in README.md doc`.
   
   -->
   
   ## Purpose of this pull request
   
   <!-- Describe the purpose of this pull request. For example: This pull request adds checkstyle plugin.-->
   improve assert sink connector
   
   
   ## Check list
   
   * [ ] Code changed are covered with tests, or it does not need tests for reason:
   * [ ] If any new Jar binary package adding in your PR, please add License Notice according
     [New License Guide](https://github.com/apache/incubator-seatunnel/blob/dev/docs/en/contribution/new-license.md)
   * [ ] If necessary, please update the documentation to describe the new feature. https://github.com/apache/incubator-seatunnel/tree/dev/docs
   


-- 
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: commits-unsubscribe@seatunnel.apache.org

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


[GitHub] [incubator-seatunnel] lhyundeadsoul commented on a diff in pull request #2844: [Feature][Connector-v2] improve assert sink connector

Posted by GitBox <gi...@apache.org>.
lhyundeadsoul commented on code in PR #2844:
URL: https://github.com/apache/incubator-seatunnel/pull/2844#discussion_r984359256


##########
docs/en/connector-v2/sink/Assert.md:
##########
@@ -47,53 +54,66 @@ The following rules are supported for now
 - MAX `define the maximum value of data`
 - MIN_LENGTH `define the minimum string length of a string data`
 - MAX_LENGTH `define the maximum string length of a string data`
+- MIN_ROW `define the minimun number of rows`
+- MAX_ROW `define the maximum number of rows`
 
 ### rule_value [double]
 
 the value related to rule type
 
-
 ## Example
 the whole config obey with `hocon` style
 
 ```hocon
 Assert {
-    rules = 
-        [{
-            field_name = name
-            field_type = string
-            field_value = [
-                {
-                    rule_type = NOT_NULL
-                },
-                {
-                    rule_type = MIN_LENGTH
-                    rule_value = 3
-                },
-                {
-                     rule_type = MAX_LENGTH
-                     rule_value = 5
-                }
-            ]
-        },{
-            field_name = age
-            field_type = int
-            field_value = [
-                {
-                    rule_type = NOT_NULL
-                },
-                {
-                    rule_type = MIN
-                    rule_value = 10
-                },
-                {
-                     rule_type = MAX
-                     rule_value = 20
-                }
-            ]
+    rules =
+      {
+        row_rules = [
+          {
+            rule_type = MAX_ROW

Review Comment:
   how about making max = min to express equal?



-- 
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: commits-unsubscribe@seatunnel.apache.org

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


[GitHub] [incubator-seatunnel] liugddx commented on a diff in pull request #2844: [Feature][Connector-v2] improve assert sink connector

Posted by GitBox <gi...@apache.org>.
liugddx commented on code in PR #2844:
URL: https://github.com/apache/incubator-seatunnel/pull/2844#discussion_r984362987


##########
docs/en/connector-v2/sink/Assert.md:
##########
@@ -47,53 +54,66 @@ The following rules are supported for now
 - MAX `define the maximum value of data`
 - MIN_LENGTH `define the minimum string length of a string data`
 - MAX_LENGTH `define the maximum string length of a string data`
+- MIN_ROW `define the minimun number of rows`
+- MAX_ROW `define the maximum number of rows`
 
 ### rule_value [double]
 
 the value related to rule type
 
-
 ## Example
 the whole config obey with `hocon` style
 
 ```hocon
 Assert {
-    rules = 
-        [{
-            field_name = name
-            field_type = string
-            field_value = [
-                {
-                    rule_type = NOT_NULL
-                },
-                {
-                    rule_type = MIN_LENGTH
-                    rule_value = 3
-                },
-                {
-                     rule_type = MAX_LENGTH
-                     rule_value = 5
-                }
-            ]
-        },{
-            field_name = age
-            field_type = int
-            field_value = [
-                {
-                    rule_type = NOT_NULL
-                },
-                {
-                    rule_type = MIN
-                    rule_value = 10
-                },
-                {
-                     rule_type = MAX
-                     rule_value = 20
-                }
-            ]
+    rules =
+      {
+        row_rules = [
+          {
+            rule_type = MAX_ROW

Review Comment:
   > how about making max = min to express equal?
   
   That's a good idea.



-- 
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: commits-unsubscribe@seatunnel.apache.org

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


[GitHub] [incubator-seatunnel] lhyundeadsoul commented on pull request #2844: [Feature][Connector-v2] improve assert sink connector

Posted by GitBox <gi...@apache.org>.
lhyundeadsoul commented on PR #2844:
URL: https://github.com/apache/incubator-seatunnel/pull/2844#issuecomment-1255934861

   please update the manual doc  `docs/en/connector-v2/sink/Assert.md`


-- 
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: commits-unsubscribe@seatunnel.apache.org

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


[GitHub] [incubator-seatunnel] lhyundeadsoul commented on a diff in pull request #2844: [Feature][Connector-v2] improve assert sink connector

Posted by GitBox <gi...@apache.org>.
lhyundeadsoul commented on code in PR #2844:
URL: https://github.com/apache/incubator-seatunnel/pull/2844#discussion_r978390223


##########
seatunnel-examples/seatunnel-flink-connector-v2-example/src/main/resources/examples/fake_to_console.conf:
##########
@@ -28,24 +28,24 @@ env {
 
 source {
   # This is a example source plugin **only for test and demonstrate the feature source plugin**
-    FakeSource {

Review Comment:
   this config file is no need to change in this PR.



##########
seatunnel-connectors-v2/connector-assert/src/main/java/org/apache/seatunnel/connectors/seatunnel/assertion/rule/AssertRowRule.java:
##########
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ */
+
+package org.apache.seatunnel.connectors.seatunnel.assertion.rule;
+
+import java.io.Serializable;
+
+public class AssertRowRule implements Serializable {

Review Comment:
   This class is useless. Maybe we should remove it first.



##########
seatunnel-connectors-v2/connector-assert/src/main/java/org/apache/seatunnel/connectors/seatunnel/assertion/sink/AssertSinkWriter.java:
##########
@@ -49,7 +54,18 @@ public void write(SeaTunnelRow element) {
 
     @Override
     public void close() throws IOException {
-        // nothing
+        assertRowRules.stream().filter(assertRule -> {

Review Comment:
   I think It is easier to understand if we use `anyMatch` instead of `filter` and `findFirst` 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.

To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org

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


[GitHub] [incubator-seatunnel] liugddx commented on pull request #2844: [Feature][Connector-v2] improve assert sink connector

Posted by GitBox <gi...@apache.org>.
liugddx commented on PR #2844:
URL: https://github.com/apache/incubator-seatunnel/pull/2844#issuecomment-1269572717

   please help to code review @EricJoy2048 @hailin0 


-- 
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: commits-unsubscribe@seatunnel.apache.org

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


[GitHub] [incubator-seatunnel] liugddx commented on pull request #2844: [Feature][Connector-v2] improve assert sink connector

Posted by GitBox <gi...@apache.org>.
liugddx commented on PR #2844:
URL: https://github.com/apache/incubator-seatunnel/pull/2844#issuecomment-1272229417

   Can this pr continue to flow?
   @EricJoy2048 @lhyundeadsoul 


-- 
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: commits-unsubscribe@seatunnel.apache.org

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


[GitHub] [incubator-seatunnel] liugddx commented on a diff in pull request #2844: [Feature][Connector-v2] improve assert sink connector

Posted by GitBox <gi...@apache.org>.
liugddx commented on code in PR #2844:
URL: https://github.com/apache/incubator-seatunnel/pull/2844#discussion_r984414344


##########
docs/en/connector-v2/sink/Assert.md:
##########
@@ -47,53 +54,66 @@ The following rules are supported for now
 - MAX `define the maximum value of data`
 - MIN_LENGTH `define the minimum string length of a string data`
 - MAX_LENGTH `define the maximum string length of a string data`
+- MIN_ROW `define the minimun number of rows`
+- MAX_ROW `define the maximum number of rows`
 
 ### rule_value [double]
 
 the value related to rule type
 
-
 ## Example
 the whole config obey with `hocon` style
 
 ```hocon
 Assert {
-    rules = 
-        [{
-            field_name = name
-            field_type = string
-            field_value = [
-                {
-                    rule_type = NOT_NULL
-                },
-                {
-                    rule_type = MIN_LENGTH
-                    rule_value = 3
-                },
-                {
-                     rule_type = MAX_LENGTH
-                     rule_value = 5
-                }
-            ]
-        },{
-            field_name = age
-            field_type = int
-            field_value = [
-                {
-                    rule_type = NOT_NULL
-                },
-                {
-                    rule_type = MIN
-                    rule_value = 10
-                },
-                {
-                     rule_type = MAX
-                     rule_value = 20
-                }
-            ]
+    rules =
+      {
+        row_rules = [
+          {
+            rule_type = MAX_ROW

Review Comment:
   > > how about making max = min to express equal?
   > 
   > I agree with you. And we must judge `max=min` after all data processing is completed.
   
   how about remove `max`and `min` and add `expected_num`



-- 
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: commits-unsubscribe@seatunnel.apache.org

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


[GitHub] [incubator-seatunnel] liugddx commented on pull request #2844: [Feature][Connector-v2] improve assert sink connector

Posted by GitBox <gi...@apache.org>.
liugddx commented on PR #2844:
URL: https://github.com/apache/incubator-seatunnel/pull/2844#issuecomment-1257836725

   > 
   
   Dneo.


-- 
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: commits-unsubscribe@seatunnel.apache.org

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


[GitHub] [incubator-seatunnel] Hisoka-X merged pull request #2844: [Feature][Connector-v2] improve assert sink connector

Posted by GitBox <gi...@apache.org>.
Hisoka-X merged PR #2844:
URL: https://github.com/apache/incubator-seatunnel/pull/2844


-- 
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: commits-unsubscribe@seatunnel.apache.org

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


[GitHub] [incubator-seatunnel] hailin0 commented on pull request #2844: [Feature][Connector-v2] improve assert sink connector

Posted by GitBox <gi...@apache.org>.
hailin0 commented on PR #2844:
URL: https://github.com/apache/incubator-seatunnel/pull/2844#issuecomment-1260464768

   <img width="1525" alt="image" src="https://user-images.githubusercontent.com/14371345/192708211-9be2abcb-c120-4409-af2e-2ef4c7113511.png">
   
   please fix ci-check


-- 
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: commits-unsubscribe@seatunnel.apache.org

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


[GitHub] [incubator-seatunnel] EricJoy2048 commented on a diff in pull request #2844: [Feature][Connector-v2] improve assert sink connector

Posted by GitBox <gi...@apache.org>.
EricJoy2048 commented on code in PR #2844:
URL: https://github.com/apache/incubator-seatunnel/pull/2844#discussion_r984392351


##########
docs/en/connector-v2/sink/Assert.md:
##########
@@ -47,53 +54,66 @@ The following rules are supported for now
 - MAX `define the maximum value of data`
 - MIN_LENGTH `define the minimum string length of a string data`
 - MAX_LENGTH `define the maximum string length of a string data`
+- MIN_ROW `define the minimun number of rows`
+- MAX_ROW `define the maximum number of rows`
 
 ### rule_value [double]
 
 the value related to rule type
 
-
 ## Example
 the whole config obey with `hocon` style
 
 ```hocon
 Assert {
-    rules = 
-        [{
-            field_name = name
-            field_type = string
-            field_value = [
-                {
-                    rule_type = NOT_NULL
-                },
-                {
-                    rule_type = MIN_LENGTH
-                    rule_value = 3
-                },
-                {
-                     rule_type = MAX_LENGTH
-                     rule_value = 5
-                }
-            ]
-        },{
-            field_name = age
-            field_type = int
-            field_value = [
-                {
-                    rule_type = NOT_NULL
-                },
-                {
-                    rule_type = MIN
-                    rule_value = 10
-                },
-                {
-                     rule_type = MAX
-                     rule_value = 20
-                }
-            ]
+    rules =
+      {
+        row_rules = [
+          {
+            rule_type = MAX_ROW

Review Comment:
   > how about making max = min to express equal?
   
   I agree with you. And we must judge `max=min` after all data processing is completed.



-- 
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: commits-unsubscribe@seatunnel.apache.org

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


[GitHub] [incubator-seatunnel] liugddx commented on pull request #2844: [Feature][Connector-v2] improve assert sink connector

Posted by GitBox <gi...@apache.org>.
liugddx commented on PR #2844:
URL: https://github.com/apache/incubator-seatunnel/pull/2844#issuecomment-1257837430

   > Thx for your contribution. Could you help to update the manual doc `docs/en/connector-v2/sink/Assert.md`?
   
   Done,thank you for your code review.


-- 
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: commits-unsubscribe@seatunnel.apache.org

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


[GitHub] [incubator-seatunnel] EricJoy2048 commented on a diff in pull request #2844: [Feature][Connector-v2] improve assert sink connector

Posted by GitBox <gi...@apache.org>.
EricJoy2048 commented on code in PR #2844:
URL: https://github.com/apache/incubator-seatunnel/pull/2844#discussion_r984416681


##########
docs/en/connector-v2/sink/Assert.md:
##########
@@ -47,53 +54,66 @@ The following rules are supported for now
 - MAX `define the maximum value of data`
 - MIN_LENGTH `define the minimum string length of a string data`
 - MAX_LENGTH `define the maximum string length of a string data`
+- MIN_ROW `define the minimun number of rows`
+- MAX_ROW `define the maximum number of rows`
 
 ### rule_value [double]
 
 the value related to rule type
 
-
 ## Example
 the whole config obey with `hocon` style
 
 ```hocon
 Assert {
-    rules = 
-        [{
-            field_name = name
-            field_type = string
-            field_value = [
-                {
-                    rule_type = NOT_NULL
-                },
-                {
-                    rule_type = MIN_LENGTH
-                    rule_value = 3
-                },
-                {
-                     rule_type = MAX_LENGTH
-                     rule_value = 5
-                }
-            ]
-        },{
-            field_name = age
-            field_type = int
-            field_value = [
-                {
-                    rule_type = NOT_NULL
-                },
-                {
-                    rule_type = MIN
-                    rule_value = 10
-                },
-                {
-                     rule_type = MAX
-                     rule_value = 20
-                }
-            ]
+    rules =
+      {
+        row_rules = [
+          {
+            rule_type = MAX_ROW

Review Comment:
   > > > how about making max = min to express equal?
   > > 
   > > 
   > > I agree with you. And we must judge `max=min` after all data processing is completed.
   > 
   > how about remove `max`and `min` and add `expected_num`
   
   Some Source Connector support AT_LEAST_ONCE, so `max` and `min` is needed.



-- 
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: commits-unsubscribe@seatunnel.apache.org

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


[GitHub] [incubator-seatunnel] EricJoy2048 commented on a diff in pull request #2844: [Feature][Connector-v2] improve assert sink connector

Posted by GitBox <gi...@apache.org>.
EricJoy2048 commented on code in PR #2844:
URL: https://github.com/apache/incubator-seatunnel/pull/2844#discussion_r984300612


##########
docs/en/connector-v2/sink/Assert.md:
##########
@@ -47,53 +54,66 @@ The following rules are supported for now
 - MAX `define the maximum value of data`
 - MIN_LENGTH `define the minimum string length of a string data`
 - MAX_LENGTH `define the maximum string length of a string data`
+- MIN_ROW `define the minimun number of rows`
+- MAX_ROW `define the maximum number of rows`
 
 ### rule_value [double]
 
 the value related to rule type
 
-
 ## Example
 the whole config obey with `hocon` style
 
 ```hocon
 Assert {
-    rules = 
-        [{
-            field_name = name
-            field_type = string
-            field_value = [
-                {
-                    rule_type = NOT_NULL
-                },
-                {
-                    rule_type = MIN_LENGTH
-                    rule_value = 3
-                },
-                {
-                     rule_type = MAX_LENGTH
-                     rule_value = 5
-                }
-            ]
-        },{
-            field_name = age
-            field_type = int
-            field_value = [
-                {
-                    rule_type = NOT_NULL
-                },
-                {
-                    rule_type = MIN
-                    rule_value = 10
-                },
-                {
-                     rule_type = MAX
-                     rule_value = 20
-                }
-            ]
+    rules =
+      {
+        row_rules = [
+          {
+            rule_type = MAX_ROW

Review Comment:
   If I want to test test final row number equals a expected value, how can I do.



-- 
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: commits-unsubscribe@seatunnel.apache.org

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


[GitHub] [incubator-seatunnel] liugddx commented on a diff in pull request #2844: [Feature][Connector-v2] improve assert sink connector

Posted by GitBox <gi...@apache.org>.
liugddx commented on code in PR #2844:
URL: https://github.com/apache/incubator-seatunnel/pull/2844#discussion_r984306453


##########
docs/en/connector-v2/sink/Assert.md:
##########
@@ -47,53 +54,66 @@ The following rules are supported for now
 - MAX `define the maximum value of data`
 - MIN_LENGTH `define the minimum string length of a string data`
 - MAX_LENGTH `define the maximum string length of a string data`
+- MIN_ROW `define the minimun number of rows`
+- MAX_ROW `define the maximum number of rows`
 
 ### rule_value [double]
 
 the value related to rule type
 
-
 ## Example
 the whole config obey with `hocon` style
 
 ```hocon
 Assert {
-    rules = 
-        [{
-            field_name = name
-            field_type = string
-            field_value = [
-                {
-                    rule_type = NOT_NULL
-                },
-                {
-                    rule_type = MIN_LENGTH
-                    rule_value = 3
-                },
-                {
-                     rule_type = MAX_LENGTH
-                     rule_value = 5
-                }
-            ]
-        },{
-            field_name = age
-            field_type = int
-            field_value = [
-                {
-                    rule_type = NOT_NULL
-                },
-                {
-                    rule_type = MIN
-                    rule_value = 10
-                },
-                {
-                     rule_type = MAX
-                     rule_value = 20
-                }
-            ]
+    rules =
+      {
+        row_rules = [
+          {
+            rule_type = MAX_ROW

Review Comment:
   > If I want to test test final row number equals a expected value, how can I do.
   
   add `EQUAL_ROW` rule_type? any good suggestions?
   
   



-- 
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: commits-unsubscribe@seatunnel.apache.org

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