You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by "ying-hua (via GitHub)" <gi...@apache.org> on 2024/08/24 06:55:18 UTC

[PR] [INLONG-10867][SDK] Transform support BETWEEN AND operator [inlong]

ying-hua opened a new pull request, #10871:
URL: https://github.com/apache/inlong/pull/10871

   <!-- Prepare a Pull Request
   Change the title of pull request refer to the following example:
     [INLONG-XYZ][Component] Title of the pull request 
   -->
   
   <!-- Specify the issue this pull request going to fix.
   The following *XYZ* should be replaced by the actual [GitHub Issue](https://github.com/apache/inlong/issues) number)-->
   
   Fixes #10867
   
   ### Motivation
   
   <!--Explain here the context, and why you're making that change. What is the problem you're trying to solve.-->
   add one BetweenOperator class to support BETWEEN AND operator.
   - x BETWEEN n AND m
   Check whether x within n and m.
   ### Modifications
   
   <!--Describe the modifications you've done.-->
   
   ### Verifying this change
   
   *(Please pick either of the following options)*
   
   - [x] This change is a trivial rework/code cleanup without any test coverage.
   
   - [ ] This change is already covered by existing tests, such as:
     *(please describe tests)*
   
   - [ ] This change added tests and can be verified as follows:
   
     *(example:)*
     - *Added integration tests for end-to-end deployment with large payloads (10MB)*
     - *Extended integration test for recovery after broker failure*
   
   ### Documentation
   
     - Does this pull request introduce a new feature? (yes / no)
     - If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)
     - If a feature is not applicable for documentation, explain why?
     - If a feature is not documented yet in this PR, please create a follow-up issue for adding the documentation
   


-- 
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@inlong.apache.org

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


Re: [PR] [INLONG-10867][SDK] Transform support BETWEEN AND operator [inlong]

Posted by "luchunliang (via GitHub)" <gi...@apache.org>.
luchunliang commented on code in PR #10871:
URL: https://github.com/apache/inlong/pull/10871#discussion_r1730737418


##########
inlong-sdk/transform-sdk/src/main/java/org/apache/inlong/sdk/transform/process/operator/BetweenOperator.java:
##########
@@ -0,0 +1,55 @@
+/*
+ * 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.inlong.sdk.transform.process.operator;
+
+import org.apache.inlong.sdk.transform.decode.SourceData;
+import org.apache.inlong.sdk.transform.process.Context;
+import org.apache.inlong.sdk.transform.process.parser.ValueParser;
+
+import net.sf.jsqlparser.expression.operators.relational.Between;
+
+/**
+ * Between operator
+ */
+public class BetweenOperator implements ExpressionOperator {
+
+    private final ValueParser left;
+    private final ValueParser start;
+    private final ValueParser end;
+
+    public BetweenOperator(Between expr) {
+        this.left = OperatorTools.buildParser(expr.getLeftExpression());
+        this.start = OperatorTools.buildParser(expr.getBetweenExpressionStart());
+        this.end = OperatorTools.buildParser(expr.getBetweenExpressionEnd());
+    }
+
+    /**
+     * check
+     * @param sourceData
+     * @param rowIndex
+     * @return
+     */
+    @SuppressWarnings("rawtypes")
+    @Override
+    public boolean check(SourceData sourceData, int rowIndex, Context context) {
+        return OperatorTools.compareValue((Comparable) this.left.parse(sourceData, rowIndex, context),
+                (Comparable) this.start.parse(sourceData, rowIndex, context)) >= 0
+                && OperatorTools.compareValue((Comparable) this.left.parse(sourceData, rowIndex, context),
+                        (Comparable) this.end.parse(sourceData, rowIndex, context)) <= 0;

Review Comment:
   It is repeat for the code "this.left.parse(sourceData, rowIndex, context)".



-- 
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@inlong.apache.org

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


Re: [PR] [INLONG-10867][SDK] Transform support BETWEEN AND operator [inlong]

Posted by "aloyszhang (via GitHub)" <gi...@apache.org>.
aloyszhang commented on code in PR #10871:
URL: https://github.com/apache/inlong/pull/10871#discussion_r1730868575


##########
inlong-sdk/transform-sdk/src/main/java/org/apache/inlong/sdk/transform/process/operator/BetweenOperator.java:
##########
@@ -0,0 +1,55 @@
+/*
+ * 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.inlong.sdk.transform.process.operator;
+
+import org.apache.inlong.sdk.transform.decode.SourceData;
+import org.apache.inlong.sdk.transform.process.Context;
+import org.apache.inlong.sdk.transform.process.parser.ValueParser;
+
+import net.sf.jsqlparser.expression.operators.relational.Between;
+
+/**
+ * Between operator

Review Comment:
   Please add more details in the description



-- 
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@inlong.apache.org

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


Re: [PR] [INLONG-10867][SDK] Transform support BETWEEN AND operator [inlong]

Posted by "ying-hua (via GitHub)" <gi...@apache.org>.
ying-hua commented on PR #10871:
URL: https://github.com/apache/inlong/pull/10871#issuecomment-2328380781

   > Please use annotation to resolve conflicting file. Please use independent UT class file to avoid UT conflicting file.
   Done. I temporarily add TestBetweenAndOperator class, it will be synchronized with #11011 later.


-- 
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@inlong.apache.org

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


Re: [PR] [INLONG-10867][SDK] Transform support BETWEEN AND operator [inlong]

Posted by "luchunliang (via GitHub)" <gi...@apache.org>.
luchunliang merged PR #10871:
URL: https://github.com/apache/inlong/pull/10871


-- 
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@inlong.apache.org

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


Re: [PR] [INLONG-10867][SDK] Transform support BETWEEN AND operator [inlong]

Posted by "luchunliang (via GitHub)" <gi...@apache.org>.
luchunliang commented on PR #10871:
URL: https://github.com/apache/inlong/pull/10871#issuecomment-2327760735

   Please use annotation to resolve conflicting file.
   Please use independent UT class file to avoid UT conflicting file.


-- 
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@inlong.apache.org

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


Re: [PR] [INLONG-10867][SDK] Transform support BETWEEN AND operator [inlong]

Posted by "luchunliang (via GitHub)" <gi...@apache.org>.
luchunliang commented on code in PR #10871:
URL: https://github.com/apache/inlong/pull/10871#discussion_r1730752309


##########
inlong-sdk/transform-sdk/src/main/java/org/apache/inlong/sdk/transform/process/operator/OperatorTools.java:
##########
@@ -165,6 +166,8 @@ public static ExpressionOperator buildOperator(Expression expr) {
             return new MinorThanOperator((MinorThan) expr);
         } else if (expr instanceof MinorThanEquals) {
             return new MinorThanEqualsOperator((MinorThanEquals) expr);
+        } else if (expr instanceof Between) {
+            return new BetweenOperator((Between) expr);

Review Comment:
   Miss unit case.



-- 
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@inlong.apache.org

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