You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by "yfsn666 (via GitHub)" <gi...@apache.org> on 2024/07/12 01:51:22 UTC

[PR] [INLONG-10607][SDK] Transform SQL support arithmetic functions(Including log10, log2, log and exp) [inlong]

yfsn666 opened a new pull request, #10615:
URL: https://github.com/apache/inlong/pull/10615

   <!-- 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 #10607 
   
   ### Motivation
   
   <!--Explain here the context, and why you're making that change. What is the problem you're trying to solve.-->
   Transform SQL support arithmetic functions(Including log10, log2, log and exp)
   
   ### Modifications
   
   <!--Describe the modifications you've done.-->
   Add four arithmetic function classes: Log2Function, Log10Function, LogFunction, and ExpFunction. Also, add the corresponding unit test codes
   
   ### Verifying this change
   
   *(Please pick either of the following options)*
   
   - [ ] This change is a trivial rework/code cleanup without any test coverage.
   
   - [x] This change is already covered by existing tests in `TestTransformArithmeticFunctionsProcessor.java`
   
   - [ ] 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
     - 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.

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-10607][SDK] Transform SQL support arithmetic functions(Including log10, log2, log and exp) [inlong]

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


##########
inlong-sdk/transform-sdk/src/test/java/org/apache/inlong/sdk/transform/process/TestTransformArithmeticFunctionsProcessor.java:
##########
@@ -117,4 +117,72 @@ public void testLnFunction() throws Exception {
         Assert.assertTrue(output2.size() == 1);
         Assert.assertEquals(output2.get(0), "result=2.302585092994046");
     }
+
+    @Test
+    public void testLog10Function() throws Exception {
+        String transformSql = "select log10(numeric1) from source";
+        TransformConfig config = new TransformConfig(csvSource, kvSink, transformSql);
+        // case1: log10(1)
+        TransformProcessor processor = new TransformProcessor(config);
+        List<String> output1 = processor.transform("1|4|6|8", new HashMap<>());
+        Assert.assertTrue(output1.size() == 1);
+        Assert.assertEquals(output1.get(0), "result=0.0");
+        // case2: log10(1000)
+        List<String> output2 = processor.transform("1000|4|6|8", new HashMap<>());
+        Assert.assertTrue(output2.size() == 1);
+        Assert.assertEquals(output2.get(0), "result=3.0");
+    }
+
+    @Test
+    public void testLog2Function() throws Exception {
+        String transformSql = "select log2(numeric1) from source";
+        TransformConfig config = new TransformConfig(csvSource, kvSink, transformSql);
+        // case1: log2(1)
+        TransformProcessor processor = new TransformProcessor(config);
+        List<String> output1 = processor.transform("1|4|6|8", new HashMap<>());
+        Assert.assertTrue(output1.size() == 1);
+        Assert.assertEquals(output1.get(0), "result=0.0");
+        // case2: log2(32)
+        List<String> output2 = processor.transform("32|4|6|8", new HashMap<>());
+        Assert.assertTrue(output2.size() == 1);

Review Comment:
   ```suggestion
           Assert.assertEquals(1, output1.size());
           Assert.assertEquals(output1.get(0), "result=0.0");
           // case2: log2(32)
           List<String> output2 = processor.transform("32|4|6|8", new HashMap<>());
           Assert.assertEquals(1, output2.size());
   ```



-- 
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-10607][SDK] Transform SQL support arithmetic functions(Including log10, log2, log and exp) [inlong]

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


##########
inlong-sdk/transform-sdk/src/test/java/org/apache/inlong/sdk/transform/process/TestTransformArithmeticFunctionsProcessor.java:
##########
@@ -117,4 +117,72 @@ public void testLnFunction() throws Exception {
         Assert.assertTrue(output2.size() == 1);
         Assert.assertEquals(output2.get(0), "result=2.302585092994046");
     }
+
+    @Test
+    public void testLog10Function() throws Exception {
+        String transformSql = "select log10(numeric1) from source";
+        TransformConfig config = new TransformConfig(csvSource, kvSink, transformSql);
+        // case1: log10(1)
+        TransformProcessor processor = new TransformProcessor(config);
+        List<String> output1 = processor.transform("1|4|6|8", new HashMap<>());
+        Assert.assertTrue(output1.size() == 1);
+        Assert.assertEquals(output1.get(0), "result=0.0");
+        // case2: log10(1000)
+        List<String> output2 = processor.transform("1000|4|6|8", new HashMap<>());
+        Assert.assertTrue(output2.size() == 1);

Review Comment:
   optimized the test code



-- 
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-10607][SDK] Transform SQL support arithmetic functions(Including log10, log2, log and exp) [inlong]

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


-- 
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-10607][SDK] Transform SQL support arithmetic functions(Including log10, log2, log and exp) [inlong]

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


##########
inlong-sdk/transform-sdk/src/main/java/org/apache/inlong/sdk/transform/process/function/ExpFunction.java:
##########
@@ -0,0 +1,56 @@
+/*
+ * 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.function;
+
+import org.apache.inlong.sdk.transform.decode.SourceData;
+import org.apache.inlong.sdk.transform.process.operator.OperatorTools;
+import org.apache.inlong.sdk.transform.process.parser.ValueParser;
+
+import net.sf.jsqlparser.expression.Function;
+
+import java.math.BigDecimal;
+
+/**
+ * ExpFunction
+ * description: exp(numeric)--returns e raised to the power of numeric
+ */
+public class ExpFunction implements ValueParser {
+
+    private ValueParser number;

Review Comment:
   renamed the relevant variables



-- 
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-10607][SDK] Transform SQL support arithmetic functions(Including log10, log2, log and exp) [inlong]

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


##########
inlong-sdk/transform-sdk/src/main/java/org/apache/inlong/sdk/transform/process/function/Log10Function.java:
##########
@@ -0,0 +1,56 @@
+/*
+ * 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.function;
+
+import org.apache.inlong.sdk.transform.decode.SourceData;
+import org.apache.inlong.sdk.transform.process.operator.OperatorTools;
+import org.apache.inlong.sdk.transform.process.parser.ValueParser;
+
+import net.sf.jsqlparser.expression.Function;
+
+import java.math.BigDecimal;
+
+/**
+ * Log10Function
+ * description: log10(numeric)--returns the base 10 logarithm of numeric
+ */
+public class Log10Function implements ValueParser {
+
+    private ValueParser number;

Review Comment:
   ditto



##########
inlong-sdk/transform-sdk/src/main/java/org/apache/inlong/sdk/transform/process/function/Log2Function.java:
##########
@@ -0,0 +1,56 @@
+/*
+ * 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.function;
+
+import org.apache.inlong.sdk.transform.decode.SourceData;
+import org.apache.inlong.sdk.transform.process.operator.OperatorTools;
+import org.apache.inlong.sdk.transform.process.parser.ValueParser;
+
+import net.sf.jsqlparser.expression.Function;
+
+import java.math.BigDecimal;
+
+/**
+ * Log2Function
+ * description: log2(numeric)--returns the base 2 logarithm of numeric
+ */
+public class Log2Function implements ValueParser {
+
+    private ValueParser number;

Review Comment:
   ditto



-- 
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-10607][SDK] Transform SQL support arithmetic functions(Including log10, log2, log and exp) [inlong]

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


##########
inlong-sdk/transform-sdk/src/main/java/org/apache/inlong/sdk/transform/process/function/Log2Function.java:
##########
@@ -0,0 +1,56 @@
+/*
+ * 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.function;
+
+import org.apache.inlong.sdk.transform.decode.SourceData;
+import org.apache.inlong.sdk.transform.process.operator.OperatorTools;
+import org.apache.inlong.sdk.transform.process.parser.ValueParser;
+
+import net.sf.jsqlparser.expression.Function;
+
+import java.math.BigDecimal;
+
+/**
+ * Log2Function
+ * description: log2(numeric)--returns the base 2 logarithm of numeric
+ */
+public class Log2Function implements ValueParser {
+
+    private ValueParser number;

Review Comment:
   parse



-- 
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-10607][SDK] Transform SQL support arithmetic functions(Including log10, log2, log and exp) [inlong]

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


##########
inlong-sdk/transform-sdk/src/test/java/org/apache/inlong/sdk/transform/process/TestTransformArithmeticFunctionsProcessor.java:
##########
@@ -117,4 +117,72 @@ public void testLnFunction() throws Exception {
         Assert.assertTrue(output2.size() == 1);
         Assert.assertEquals(output2.get(0), "result=2.302585092994046");
     }
+
+    @Test
+    public void testLog10Function() throws Exception {
+        String transformSql = "select log10(numeric1) from source";
+        TransformConfig config = new TransformConfig(csvSource, kvSink, transformSql);
+        // case1: log10(1)
+        TransformProcessor processor = new TransformProcessor(config);
+        List<String> output1 = processor.transform("1|4|6|8", new HashMap<>());
+        Assert.assertTrue(output1.size() == 1);
+        Assert.assertEquals(output1.get(0), "result=0.0");
+        // case2: log10(1000)
+        List<String> output2 = processor.transform("1000|4|6|8", new HashMap<>());
+        Assert.assertTrue(output2.size() == 1);

Review Comment:
   ```suggestion
            Assert.assertEquals(1, output1.size());
           Assert.assertEquals(output1.get(0), "result=0.0");
           // case2: log10(1000)
           List<String> output2 = processor.transform("1000|4|6|8", new HashMap<>());
           Assert.assertEquals(1, output2.size());
   ```



-- 
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-10607][SDK] Transform SQL support arithmetic functions(Including log10, log2, log and exp) [inlong]

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


##########
inlong-sdk/transform-sdk/src/test/java/org/apache/inlong/sdk/transform/process/TestTransformArithmeticFunctionsProcessor.java:
##########
@@ -117,4 +117,72 @@ public void testLnFunction() throws Exception {
         Assert.assertTrue(output2.size() == 1);
         Assert.assertEquals(output2.get(0), "result=2.302585092994046");
     }
+
+    @Test
+    public void testLog10Function() throws Exception {
+        String transformSql = "select log10(numeric1) from source";
+        TransformConfig config = new TransformConfig(csvSource, kvSink, transformSql);
+        // case1: log10(1)
+        TransformProcessor processor = new TransformProcessor(config);
+        List<String> output1 = processor.transform("1|4|6|8", new HashMap<>());
+        Assert.assertTrue(output1.size() == 1);
+        Assert.assertEquals(output1.get(0), "result=0.0");
+        // case2: log10(1000)
+        List<String> output2 = processor.transform("1000|4|6|8", new HashMap<>());
+        Assert.assertTrue(output2.size() == 1);
+        Assert.assertEquals(output2.get(0), "result=3.0");
+    }
+
+    @Test
+    public void testLog2Function() throws Exception {
+        String transformSql = "select log2(numeric1) from source";
+        TransformConfig config = new TransformConfig(csvSource, kvSink, transformSql);
+        // case1: log2(1)
+        TransformProcessor processor = new TransformProcessor(config);
+        List<String> output1 = processor.transform("1|4|6|8", new HashMap<>());
+        Assert.assertTrue(output1.size() == 1);
+        Assert.assertEquals(output1.get(0), "result=0.0");
+        // case2: log2(32)
+        List<String> output2 = processor.transform("32|4|6|8", new HashMap<>());
+        Assert.assertTrue(output2.size() == 1);
+        Assert.assertEquals(output2.get(0), "result=5.0");
+    }
+
+    @Test
+    public void testLogFunction() throws Exception {
+        String transformSql1 = "select log(numeric1) from source";
+        TransformConfig config1 = new TransformConfig(csvSource, kvSink, transformSql1);
+        // case1: ln(1)
+        TransformProcessor processor1 = new TransformProcessor(config1);
+        List<String> output1 = processor1.transform("1|4|6|8", new HashMap<>());
+        Assert.assertTrue(output1.size() == 1);
+        Assert.assertEquals(output1.get(0), "result=0.0");
+        String transformSql2 = "select log(numeric1, numeric2) from source";
+        TransformConfig config2 = new TransformConfig(csvSource, kvSink, transformSql2);
+        // case2: log2(8)
+        TransformProcessor processor2 = new TransformProcessor(config2);
+        List<String> output2 = processor2.transform("2|8|6|8", new HashMap<>());
+        Assert.assertTrue(output2.size() == 1);
+        Assert.assertEquals(output2.get(0), "result=3.0");
+        // case3: log10(100)
+        TransformProcessor processor3 = new TransformProcessor(config2);
+        List<String> output3 = processor3.transform("10|100|6|8", new HashMap<>());
+        Assert.assertTrue(output3.size() == 1);
+        Assert.assertEquals(output3.get(0), "result=2.0");
+    }
+
+    @Test
+    public void testExpFunction() throws Exception {
+        String transformSql = "select exp(numeric1) from source";
+        TransformConfig config = new TransformConfig(csvSource, kvSink, transformSql);
+        // case1: e^0
+        TransformProcessor processor = new TransformProcessor(config);
+        List<String> output1 = processor.transform("0|4|6|8", new HashMap<>());
+        Assert.assertTrue(output1.size() == 1);
+        Assert.assertEquals(output1.get(0), "result=1.0");
+        // case2: e^2
+        List<String> output2 = processor.transform("2|4|6|8", new HashMap<>());
+        Assert.assertTrue(output2.size() == 1);

Review Comment:
   ```suggestion
           Assert.assertEquals(1, output1.size());
           Assert.assertEquals(output1.get(0), "result=1.0");
           // case2: e^2
           List<String> output2 = processor.transform("2|4|6|8", new HashMap<>());
           Assert.assertEquals(1, output2.size());
   ```



-- 
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-10607][SDK] Transform SQL support arithmetic functions(Including log10, log2, log and exp) [inlong]

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


##########
inlong-sdk/transform-sdk/src/test/java/org/apache/inlong/sdk/transform/process/TestTransformArithmeticFunctionsProcessor.java:
##########
@@ -117,4 +117,72 @@ public void testLnFunction() throws Exception {
         Assert.assertTrue(output2.size() == 1);
         Assert.assertEquals(output2.get(0), "result=2.302585092994046");
     }
+
+    @Test
+    public void testLog10Function() throws Exception {
+        String transformSql = "select log10(numeric1) from source";
+        TransformConfig config = new TransformConfig(csvSource, kvSink, transformSql);
+        // case1: log10(1)
+        TransformProcessor processor = new TransformProcessor(config);
+        List<String> output1 = processor.transform("1|4|6|8", new HashMap<>());
+        Assert.assertTrue(output1.size() == 1);
+        Assert.assertEquals(output1.get(0), "result=0.0");
+        // case2: log10(1000)
+        List<String> output2 = processor.transform("1000|4|6|8", new HashMap<>());
+        Assert.assertTrue(output2.size() == 1);
+        Assert.assertEquals(output2.get(0), "result=3.0");
+    }
+
+    @Test
+    public void testLog2Function() throws Exception {
+        String transformSql = "select log2(numeric1) from source";
+        TransformConfig config = new TransformConfig(csvSource, kvSink, transformSql);
+        // case1: log2(1)
+        TransformProcessor processor = new TransformProcessor(config);
+        List<String> output1 = processor.transform("1|4|6|8", new HashMap<>());
+        Assert.assertTrue(output1.size() == 1);
+        Assert.assertEquals(output1.get(0), "result=0.0");
+        // case2: log2(32)
+        List<String> output2 = processor.transform("32|4|6|8", new HashMap<>());
+        Assert.assertTrue(output2.size() == 1);
+        Assert.assertEquals(output2.get(0), "result=5.0");
+    }
+
+    @Test
+    public void testLogFunction() throws Exception {
+        String transformSql1 = "select log(numeric1) from source";
+        TransformConfig config1 = new TransformConfig(csvSource, kvSink, transformSql1);
+        // case1: ln(1)
+        TransformProcessor processor1 = new TransformProcessor(config1);
+        List<String> output1 = processor1.transform("1|4|6|8", new HashMap<>());
+        Assert.assertTrue(output1.size() == 1);
+        Assert.assertEquals(output1.get(0), "result=0.0");
+        String transformSql2 = "select log(numeric1, numeric2) from source";
+        TransformConfig config2 = new TransformConfig(csvSource, kvSink, transformSql2);
+        // case2: log2(8)
+        TransformProcessor processor2 = new TransformProcessor(config2);
+        List<String> output2 = processor2.transform("2|8|6|8", new HashMap<>());
+        Assert.assertTrue(output2.size() == 1);

Review Comment:
   ```suggestion
           Assert.assertEquals(1, output2.size());
   ```



##########
inlong-sdk/transform-sdk/src/test/java/org/apache/inlong/sdk/transform/process/TestTransformArithmeticFunctionsProcessor.java:
##########
@@ -117,4 +117,72 @@ public void testLnFunction() throws Exception {
         Assert.assertTrue(output2.size() == 1);
         Assert.assertEquals(output2.get(0), "result=2.302585092994046");
     }
+
+    @Test
+    public void testLog10Function() throws Exception {
+        String transformSql = "select log10(numeric1) from source";
+        TransformConfig config = new TransformConfig(csvSource, kvSink, transformSql);
+        // case1: log10(1)
+        TransformProcessor processor = new TransformProcessor(config);
+        List<String> output1 = processor.transform("1|4|6|8", new HashMap<>());
+        Assert.assertTrue(output1.size() == 1);
+        Assert.assertEquals(output1.get(0), "result=0.0");
+        // case2: log10(1000)
+        List<String> output2 = processor.transform("1000|4|6|8", new HashMap<>());
+        Assert.assertTrue(output2.size() == 1);
+        Assert.assertEquals(output2.get(0), "result=3.0");
+    }
+
+    @Test
+    public void testLog2Function() throws Exception {
+        String transformSql = "select log2(numeric1) from source";
+        TransformConfig config = new TransformConfig(csvSource, kvSink, transformSql);
+        // case1: log2(1)
+        TransformProcessor processor = new TransformProcessor(config);
+        List<String> output1 = processor.transform("1|4|6|8", new HashMap<>());
+        Assert.assertTrue(output1.size() == 1);
+        Assert.assertEquals(output1.get(0), "result=0.0");
+        // case2: log2(32)
+        List<String> output2 = processor.transform("32|4|6|8", new HashMap<>());
+        Assert.assertTrue(output2.size() == 1);
+        Assert.assertEquals(output2.get(0), "result=5.0");
+    }
+
+    @Test
+    public void testLogFunction() throws Exception {
+        String transformSql1 = "select log(numeric1) from source";
+        TransformConfig config1 = new TransformConfig(csvSource, kvSink, transformSql1);
+        // case1: ln(1)
+        TransformProcessor processor1 = new TransformProcessor(config1);
+        List<String> output1 = processor1.transform("1|4|6|8", new HashMap<>());
+        Assert.assertTrue(output1.size() == 1);
+        Assert.assertEquals(output1.get(0), "result=0.0");
+        String transformSql2 = "select log(numeric1, numeric2) from source";
+        TransformConfig config2 = new TransformConfig(csvSource, kvSink, transformSql2);
+        // case2: log2(8)
+        TransformProcessor processor2 = new TransformProcessor(config2);
+        List<String> output2 = processor2.transform("2|8|6|8", new HashMap<>());
+        Assert.assertTrue(output2.size() == 1);
+        Assert.assertEquals(output2.get(0), "result=3.0");
+        // case3: log10(100)
+        TransformProcessor processor3 = new TransformProcessor(config2);
+        List<String> output3 = processor3.transform("10|100|6|8", new HashMap<>());
+        Assert.assertTrue(output3.size() == 1);

Review Comment:
   ```suggestion
           Assert.assertEquals(1, output3.size());
   ```



-- 
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-10607][SDK] Transform SQL support arithmetic functions(Including log10, log2, log and exp) [inlong]

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


##########
inlong-sdk/transform-sdk/src/main/java/org/apache/inlong/sdk/transform/process/function/LogFunction.java:
##########
@@ -0,0 +1,73 @@
+/*
+ * 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.function;
+
+import org.apache.inlong.sdk.transform.decode.SourceData;
+import org.apache.inlong.sdk.transform.process.operator.OperatorTools;
+import org.apache.inlong.sdk.transform.process.parser.ValueParser;
+
+import net.sf.jsqlparser.expression.Expression;
+import net.sf.jsqlparser.expression.Function;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+/**
+ * LogFunction
+ * description: log(numeric) or log(numeric1, numeric2)--When called with one argument, returns the natural logarithm
+ * of numeric. When called with two arguments, this function returns the logarithm of numeric2 to the base numeric1
+ */
+public class LogFunction implements ValueParser {
+
+    private ValueParser base;
+    private ValueParser number;

Review Comment:
   ```suggestion
       private ValueParser baseParse;
       private ValueParser parse;
   ```



-- 
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-10607][SDK] Transform SQL support arithmetic functions(Including log10, log2, log and exp) [inlong]

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


##########
inlong-sdk/transform-sdk/src/main/java/org/apache/inlong/sdk/transform/process/function/Log10Function.java:
##########
@@ -0,0 +1,56 @@
+/*
+ * 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.function;
+
+import org.apache.inlong.sdk.transform.decode.SourceData;
+import org.apache.inlong.sdk.transform.process.operator.OperatorTools;
+import org.apache.inlong.sdk.transform.process.parser.ValueParser;
+
+import net.sf.jsqlparser.expression.Function;
+
+import java.math.BigDecimal;
+
+/**
+ * Log10Function
+ * description: log10(numeric)--returns the base 10 logarithm of numeric
+ */
+public class Log10Function implements ValueParser {
+
+    private ValueParser number;

Review Comment:
   ditto



-- 
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-10607][SDK] Transform SQL support arithmetic functions(Including log10, log2, log and exp) [inlong]

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


##########
inlong-sdk/transform-sdk/src/main/java/org/apache/inlong/sdk/transform/process/function/ExpFunction.java:
##########
@@ -0,0 +1,56 @@
+/*
+ * 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.function;
+
+import org.apache.inlong.sdk.transform.decode.SourceData;
+import org.apache.inlong.sdk.transform.process.operator.OperatorTools;
+import org.apache.inlong.sdk.transform.process.parser.ValueParser;
+
+import net.sf.jsqlparser.expression.Function;
+
+import java.math.BigDecimal;
+
+/**
+ * ExpFunction
+ * description: exp(numeric)--returns e raised to the power of numeric
+ */
+public class ExpFunction implements ValueParser {
+
+    private ValueParser number;

Review Comment:
   ```suggestion
       private ValueParser parse;
   ```



-- 
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-10607][SDK] Transform SQL support arithmetic functions(Including log10, log2, log and exp) [inlong]

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


##########
inlong-sdk/transform-sdk/src/main/java/org/apache/inlong/sdk/transform/process/function/Log10Function.java:
##########
@@ -0,0 +1,56 @@
+/*
+ * 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.function;
+
+import org.apache.inlong.sdk.transform.decode.SourceData;
+import org.apache.inlong.sdk.transform.process.operator.OperatorTools;
+import org.apache.inlong.sdk.transform.process.parser.ValueParser;
+
+import net.sf.jsqlparser.expression.Function;
+
+import java.math.BigDecimal;
+
+/**
+ * Log10Function
+ * description: log10(numeric)--returns the base 10 logarithm of numeric
+ */
+public class Log10Function implements ValueParser {
+
+    private ValueParser number;

Review Comment:
   ```suggestion
       private ValueParser parser;
   ```



##########
inlong-sdk/transform-sdk/src/main/java/org/apache/inlong/sdk/transform/process/function/ExpFunction.java:
##########
@@ -0,0 +1,56 @@
+/*
+ * 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.function;
+
+import org.apache.inlong.sdk.transform.decode.SourceData;
+import org.apache.inlong.sdk.transform.process.operator.OperatorTools;
+import org.apache.inlong.sdk.transform.process.parser.ValueParser;
+
+import net.sf.jsqlparser.expression.Function;
+
+import java.math.BigDecimal;
+
+/**
+ * ExpFunction
+ * description: exp(numeric)--returns e raised to the power of numeric
+ */
+public class ExpFunction implements ValueParser {
+
+    private ValueParser number;

Review Comment:
   ```suggestion
       private ValueParser parser;
   ```



-- 
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-10607][SDK] Transform SQL support arithmetic functions(Including log10, log2, log and exp) [inlong]

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


##########
inlong-sdk/transform-sdk/src/main/java/org/apache/inlong/sdk/transform/process/function/Log10Function.java:
##########
@@ -0,0 +1,56 @@
+/*
+ * 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.function;
+
+import org.apache.inlong.sdk.transform.decode.SourceData;
+import org.apache.inlong.sdk.transform.process.operator.OperatorTools;
+import org.apache.inlong.sdk.transform.process.parser.ValueParser;
+
+import net.sf.jsqlparser.expression.Function;
+
+import java.math.BigDecimal;
+
+/**
+ * Log10Function
+ * description: log10(numeric)--returns the base 10 logarithm of numeric
+ */
+public class Log10Function implements ValueParser {
+
+    private ValueParser number;

Review Comment:
   ```suggestion
       private ValueParser parse;
   ```



##########
inlong-sdk/transform-sdk/src/main/java/org/apache/inlong/sdk/transform/process/function/Log2Function.java:
##########
@@ -0,0 +1,56 @@
+/*
+ * 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.function;
+
+import org.apache.inlong.sdk.transform.decode.SourceData;
+import org.apache.inlong.sdk.transform.process.operator.OperatorTools;
+import org.apache.inlong.sdk.transform.process.parser.ValueParser;
+
+import net.sf.jsqlparser.expression.Function;
+
+import java.math.BigDecimal;
+
+/**
+ * Log2Function
+ * description: log2(numeric)--returns the base 2 logarithm of numeric
+ */
+public class Log2Function implements ValueParser {
+
+    private ValueParser number;

Review Comment:
   ditto



-- 
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-10607][SDK] Transform SQL support arithmetic functions(Including log10, log2, log and exp) [inlong]

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


##########
inlong-sdk/transform-sdk/src/main/java/org/apache/inlong/sdk/transform/process/function/Log2Function.java:
##########
@@ -0,0 +1,56 @@
+/*
+ * 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.function;
+
+import org.apache.inlong.sdk.transform.decode.SourceData;
+import org.apache.inlong.sdk.transform.process.operator.OperatorTools;
+import org.apache.inlong.sdk.transform.process.parser.ValueParser;
+
+import net.sf.jsqlparser.expression.Function;
+
+import java.math.BigDecimal;
+
+/**
+ * Log2Function
+ * description: log2(numeric)--returns the base 2 logarithm of numeric
+ */
+public class Log2Function implements ValueParser {
+
+    private ValueParser number;

Review Comment:
   parse



##########
inlong-sdk/transform-sdk/src/main/java/org/apache/inlong/sdk/transform/process/function/Log2Function.java:
##########
@@ -0,0 +1,56 @@
+/*
+ * 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.function;
+
+import org.apache.inlong.sdk.transform.decode.SourceData;
+import org.apache.inlong.sdk.transform.process.operator.OperatorTools;
+import org.apache.inlong.sdk.transform.process.parser.ValueParser;
+
+import net.sf.jsqlparser.expression.Function;
+
+import java.math.BigDecimal;
+
+/**
+ * Log2Function
+ * description: log2(numeric)--returns the base 2 logarithm of numeric
+ */
+public class Log2Function implements ValueParser {
+
+    private ValueParser number;

Review Comment:
   ```suggestion
       private ValueParser parser;
   ```



-- 
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-10607][SDK] Transform SQL support arithmetic functions(Including log10, log2, log and exp) [inlong]

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


##########
inlong-sdk/transform-sdk/src/test/java/org/apache/inlong/sdk/transform/process/TestTransformArithmeticFunctionsProcessor.java:
##########
@@ -117,4 +117,72 @@ public void testLnFunction() throws Exception {
         Assert.assertTrue(output2.size() == 1);
         Assert.assertEquals(output2.get(0), "result=2.302585092994046");
     }
+
+    @Test
+    public void testLog10Function() throws Exception {
+        String transformSql = "select log10(numeric1) from source";
+        TransformConfig config = new TransformConfig(csvSource, kvSink, transformSql);
+        // case1: log10(1)
+        TransformProcessor processor = new TransformProcessor(config);
+        List<String> output1 = processor.transform("1|4|6|8", new HashMap<>());
+        Assert.assertTrue(output1.size() == 1);
+        Assert.assertEquals(output1.get(0), "result=0.0");
+        // case2: log10(1000)
+        List<String> output2 = processor.transform("1000|4|6|8", new HashMap<>());
+        Assert.assertTrue(output2.size() == 1);
+        Assert.assertEquals(output2.get(0), "result=3.0");
+    }
+
+    @Test
+    public void testLog2Function() throws Exception {
+        String transformSql = "select log2(numeric1) from source";
+        TransformConfig config = new TransformConfig(csvSource, kvSink, transformSql);
+        // case1: log2(1)
+        TransformProcessor processor = new TransformProcessor(config);
+        List<String> output1 = processor.transform("1|4|6|8", new HashMap<>());
+        Assert.assertTrue(output1.size() == 1);
+        Assert.assertEquals(output1.get(0), "result=0.0");
+        // case2: log2(32)
+        List<String> output2 = processor.transform("32|4|6|8", new HashMap<>());
+        Assert.assertTrue(output2.size() == 1);
+        Assert.assertEquals(output2.get(0), "result=5.0");
+    }
+
+    @Test
+    public void testLogFunction() throws Exception {
+        String transformSql1 = "select log(numeric1) from source";
+        TransformConfig config1 = new TransformConfig(csvSource, kvSink, transformSql1);
+        // case1: ln(1)
+        TransformProcessor processor1 = new TransformProcessor(config1);
+        List<String> output1 = processor1.transform("1|4|6|8", new HashMap<>());
+        Assert.assertTrue(output1.size() == 1);

Review Comment:
   ```suggestion
           Assert.assertEquals(1, output1.size());
   ```



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