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

[PR] [INLONG-10816][SDK] Transform support Replace function. [inlong]

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

   <!-- 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 #10816 
   
   ### Motivation
   Add one string function class:ReplaceFunction. 
   Add the corresponding unit test codes
   <!--Explain here the context, and why you're making that change. What is the problem you're trying to solve.-->
   
   ### Modifications
   
   <!--Describe the modifications you've done.-->
   
   ### 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, 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*
   
   


-- 
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-10816][SDK] Transform support Replace function. [inlong]

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


##########
inlong-sdk/transform-sdk/src/main/java/org/apache/inlong/sdk/transform/process/function/ReplaceFunction.java:
##########
@@ -0,0 +1,61 @@
+/*
+ * 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.Context;
+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.util.List;
+
+/**
+ * ReplaceFunction
+ * description: replace(s, s1, s2)--replace string s1 in string s with string s2.
+ */
+public class ReplaceFunction implements ValueParser {
+
+    private ValueParser stringParser1;
+    private ValueParser stringParser2;
+    private ValueParser stringParser3;
+
+    /**
+     * Constructor
+     * @param expr
+     */
+    public ReplaceFunction(Function expr) {
+        List<Expression> expressions = expr.getParameters().getExpressions();
+        stringParser1 = OperatorTools.buildParser(expressions.get(0));
+        stringParser2 = OperatorTools.buildParser(expressions.get(1));
+        stringParser3 = OperatorTools.buildParser(expressions.get(2));
+    }
+
+    @Override
+    public Object parse(SourceData sourceData, int rowIndex, Context context) {
+        Object stringObj1 = stringParser1.parse(sourceData, rowIndex, context);
+        Object stringObj2 = stringParser2.parse(sourceData, rowIndex, context);
+        Object stringObj3 = stringParser3.parse(sourceData, rowIndex, context);
+        String str1 = OperatorTools.parseString(stringObj1);
+        String str2 = OperatorTools.parseString(stringObj2);
+        String str3 = OperatorTools.parseString(stringObj3);
+        return str1.replace(str2.charAt(0), str3.charAt(0));

Review Comment:
   Resolved



-- 
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-10816][SDK] Transform support Replace function. [inlong]

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


##########
inlong-sdk/transform-sdk/src/test/java/org/apache/inlong/sdk/transform/process/TestTransformStringFunctionsProcessor.java:
##########
@@ -118,6 +119,20 @@ public void testLocateFunction() throws Exception {
         Assert.assertEquals(1, output5.size());
         Assert.assertEquals(output5.get(0), "result=null");
     }
+
+    @Test
+    public void testReplaceFunction() throws Exception {
+        String transformSql = "select replace(string1, string2, string3) from source";
+        TransformConfig config = new TransformConfig(transformSql);
+        TransformProcessor<String, String> processor = TransformProcessor
+                .create(config, SourceDecoderFactory.createCsvDecoder(csvSource),
+                        SinkEncoderFactory.createKvEncoder(kvSink));
+        // case1: replace('hooray', 'oray', 'lly')
+        List<String> output = processor.transform("hooray|oray|lly", new HashMap<>());
+        Assert.assertEquals(1, output.size());
+        Assert.assertEquals(output.get(0), "result=holly");
+    }

Review Comment:
   Thanks,i will add more 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


Re: [PR] [INLONG-10816][SDK] Transform support Replace function. [inlong]

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


##########
inlong-sdk/transform-sdk/src/test/java/org/apache/inlong/sdk/transform/process/TestTransformStringFunctionsProcessor.java:
##########
@@ -118,6 +119,20 @@ public void testLocateFunction() throws Exception {
         Assert.assertEquals(1, output5.size());
         Assert.assertEquals(output5.get(0), "result=null");
     }
+
+    @Test
+    public void testReplaceFunction() throws Exception {
+        String transformSql = "select replace(string1, string2, string3) from source";
+        TransformConfig config = new TransformConfig(transformSql);
+        TransformProcessor<String, String> processor = TransformProcessor
+                .create(config, SourceDecoderFactory.createCsvDecoder(csvSource),
+                        SinkEncoderFactory.createKvEncoder(kvSink));
+        // case1: replace('hooray', 'oray', 'lly')
+        List<String> output = processor.transform("hooray|oray|lly", new HashMap<>());
+        Assert.assertEquals(1, output.size());
+        Assert.assertEquals(output.get(0), "result=holly");
+    }

Review Comment:
   It is better to add more test cases to cover the common usage scenarios. In this example, you can add a case that string `s` doesn't contains string `s1`.



-- 
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-10816][SDK] Transform support Replace function. [inlong]

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


##########
inlong-sdk/transform-sdk/src/main/java/org/apache/inlong/sdk/transform/process/function/ReplaceFunction.java:
##########
@@ -0,0 +1,61 @@
+/*
+ * 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.Context;
+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.util.List;
+
+/**
+ * ReplaceFunction
+ * description: replace(s, s1, s2)--replace string s1 in string s with string s2.
+ */
+public class ReplaceFunction implements ValueParser {
+
+    private ValueParser stringParser1;

Review Comment:
   Use more specific variable names



-- 
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-10816][SDK] Transform support Replace function. [inlong]

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


##########
inlong-sdk/transform-sdk/src/main/java/org/apache/inlong/sdk/transform/process/function/ReplaceFunction.java:
##########
@@ -0,0 +1,67 @@
+/*
+ * 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.Context;
+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.util.List;
+
+/**
+ * ReplaceFunction
+ * description: replace(s, s1, s2)--replace string s1 in string s with string s2.
+ */
+public class ReplaceFunction implements ValueParser {
+
+    private ValueParser stringParser;
+    private ValueParser targetParser;
+    private ValueParser replacementParser;
+
+    /**
+     * Constructor
+     * @param expr
+     */

Review Comment:
   resolved



-- 
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-10816][SDK] Transform support Replace function. [inlong]

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


##########
inlong-sdk/transform-sdk/src/main/java/org/apache/inlong/sdk/transform/process/function/ReplaceFunction.java:
##########
@@ -0,0 +1,67 @@
+/*
+ * 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.Context;
+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.util.List;
+
+/**
+ * ReplaceFunction
+ * description: replace(s, s1, s2)--replace string s1 in string s with string s2.
+ */
+public class ReplaceFunction implements ValueParser {
+
+    private ValueParser stringParser;
+    private ValueParser targetParser;
+    private ValueParser replacementParser;
+
+    /**
+     * Constructor
+     * @param expr
+     */
+    public ReplaceFunction(Function expr) {
+        List<Expression> expressions = expr.getParameters().getExpressions();
+        stringParser = OperatorTools.buildParser(expressions.get(0));
+        targetParser = OperatorTools.buildParser(expressions.get(1));
+        replacementParser = OperatorTools.buildParser(expressions.get(2));
+    }
+
+    /**
+     * parse
+     * @param sourceData
+     * @param rowIndex
+     * @return
+     */

Review Comment:
   resolved



-- 
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-10816][SDK] Transform support Replace function. [inlong]

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


##########
inlong-sdk/transform-sdk/src/main/java/org/apache/inlong/sdk/transform/process/function/ReplaceFunction.java:
##########
@@ -0,0 +1,61 @@
+/*
+ * 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.Context;
+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.util.List;
+
+/**
+ * ReplaceFunction
+ * description: replace(s, s1, s2)--replace string s1 in string s with string s2.
+ */
+public class ReplaceFunction implements ValueParser {
+
+    private ValueParser stringParser1;

Review Comment:
   Resolved



-- 
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-10816][SDK] Transform support Replace function. [inlong]

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


##########
inlong-sdk/transform-sdk/src/main/java/org/apache/inlong/sdk/transform/process/function/ReplaceFunction.java:
##########
@@ -0,0 +1,61 @@
+/*
+ * 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.Context;
+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.util.List;
+
+/**
+ * ReplaceFunction
+ * description: replace(s, s1, s2)--replace string s1 in string s with string s2.
+ */
+public class ReplaceFunction implements ValueParser {
+
+    private ValueParser stringParser1;
+    private ValueParser stringParser2;
+    private ValueParser stringParser3;
+
+    /**
+     * Constructor
+     * @param expr
+     */
+    public ReplaceFunction(Function expr) {
+        List<Expression> expressions = expr.getParameters().getExpressions();
+        stringParser1 = OperatorTools.buildParser(expressions.get(0));
+        stringParser2 = OperatorTools.buildParser(expressions.get(1));
+        stringParser3 = OperatorTools.buildParser(expressions.get(2));
+    }
+
+    @Override
+    public Object parse(SourceData sourceData, int rowIndex, Context context) {
+        Object stringObj1 = stringParser1.parse(sourceData, rowIndex, context);
+        Object stringObj2 = stringParser2.parse(sourceData, rowIndex, context);
+        Object stringObj3 = stringParser3.parse(sourceData, rowIndex, context);
+        String str1 = OperatorTools.parseString(stringObj1);
+        String str2 = OperatorTools.parseString(stringObj2);
+        String str3 = OperatorTools.parseString(stringObj3);
+        return str1.replace(str2.charAt(0), str3.charAt(0));

Review Comment:
   It's more like replace single char instead of a string



-- 
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-10816][SDK] Transform support Replace function. [inlong]

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

   plz rebase the master to resolve the conflict


-- 
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-10816][SDK] Transform support Replace function. [inlong]

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


-- 
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-10816][SDK] Transform support Replace function. [inlong]

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


##########
inlong-sdk/transform-sdk/src/main/java/org/apache/inlong/sdk/transform/process/function/ReplaceFunction.java:
##########
@@ -0,0 +1,67 @@
+/*
+ * 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.Context;
+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.util.List;
+
+/**
+ * ReplaceFunction
+ * description: replace(s, s1, s2)--replace string s1 in string s with string s2.
+ */
+public class ReplaceFunction implements ValueParser {
+
+    private ValueParser stringParser;
+    private ValueParser targetParser;
+    private ValueParser replacementParser;
+
+    /**
+     * Constructor
+     * @param expr
+     */

Review Comment:
   add meaningful docs or just remove it



##########
inlong-sdk/transform-sdk/src/main/java/org/apache/inlong/sdk/transform/process/function/ReplaceFunction.java:
##########
@@ -0,0 +1,67 @@
+/*
+ * 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.Context;
+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.util.List;
+
+/**
+ * ReplaceFunction
+ * description: replace(s, s1, s2)--replace string s1 in string s with string s2.
+ */
+public class ReplaceFunction implements ValueParser {
+
+    private ValueParser stringParser;
+    private ValueParser targetParser;
+    private ValueParser replacementParser;
+
+    /**
+     * Constructor
+     * @param expr
+     */
+    public ReplaceFunction(Function expr) {
+        List<Expression> expressions = expr.getParameters().getExpressions();
+        stringParser = OperatorTools.buildParser(expressions.get(0));
+        targetParser = OperatorTools.buildParser(expressions.get(1));
+        replacementParser = OperatorTools.buildParser(expressions.get(2));
+    }
+
+    /**
+     * parse
+     * @param sourceData
+     * @param rowIndex
+     * @return
+     */

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-10816][SDK] Transform support Replace function. [inlong]

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

   please resolve the conflict


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