You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by he...@apache.org on 2022/05/07 11:49:05 UTC
[incubator-inlong] branch master updated: [INLONG-3835][Sort] Register CascadeFunctionWrapper in the parent interface (#4107)
This is an automated email from the ASF dual-hosted git repository.
healchow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-inlong.git
The following commit(s) were added to refs/heads/master by this push:
new 92bb6ebe7 [INLONG-3835][Sort] Register CascadeFunctionWrapper in the parent interface (#4107)
92bb6ebe7 is described below
commit 92bb6ebe7cac3699fceabf775fde2329845eef1a
Author: yunqingmoswu <44...@users.noreply.github.com>
AuthorDate: Sat May 7 19:49:00 2022 +0800
[INLONG-3835][Sort] Register CascadeFunctionWrapper in the parent interface (#4107)
---
.../sort/protocol/transformation/Function.java | 4 +-
.../protocol/transformation/FunctionParam.java | 4 +-
.../function/CascadeFunctionWrapperTest.java | 51 ++++++++++++++++++++++
3 files changed, 57 insertions(+), 2 deletions(-)
diff --git a/inlong-sort/sort-common/src/main/java/org/apache/inlong/sort/protocol/transformation/Function.java b/inlong-sort/sort-common/src/main/java/org/apache/inlong/sort/protocol/transformation/Function.java
index ef8a4fe90..2ef8be7cb 100644
--- a/inlong-sort/sort-common/src/main/java/org/apache/inlong/sort/protocol/transformation/Function.java
+++ b/inlong-sort/sort-common/src/main/java/org/apache/inlong/sort/protocol/transformation/Function.java
@@ -20,6 +20,7 @@ package org.apache.inlong.sort.protocol.transformation;
import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonIgnore;
import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonSubTypes;
import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonTypeInfo;
+import org.apache.inlong.sort.protocol.transformation.function.CascadeFunctionWrapper;
import org.apache.inlong.sort.protocol.transformation.function.HopEndFunction;
import org.apache.inlong.sort.protocol.transformation.function.HopFunction;
import org.apache.inlong.sort.protocol.transformation.function.HopStartFunction;
@@ -56,7 +57,8 @@ import java.util.List;
@JsonSubTypes.Type(value = MultiValueFilterFunction.class, name = "multiValueFilter"),
@JsonSubTypes.Type(value = SplitIndexFunction.class, name = "splitIndex"),
@JsonSubTypes.Type(value = RegexpReplaceFunction.class, name = "regexpReplace"),
- @JsonSubTypes.Type(value = RegexpReplaceFirstFunction.class, name = "regexpReplaceFirst")
+ @JsonSubTypes.Type(value = RegexpReplaceFirstFunction.class, name = "regexpReplaceFirst"),
+ @JsonSubTypes.Type(value = CascadeFunctionWrapper.class, name = "cascadeFunctionWrapper")
})
public interface Function extends FunctionParam {
diff --git a/inlong-sort/sort-common/src/main/java/org/apache/inlong/sort/protocol/transformation/FunctionParam.java b/inlong-sort/sort-common/src/main/java/org/apache/inlong/sort/protocol/transformation/FunctionParam.java
index a86b7f2a8..cca2fb755 100644
--- a/inlong-sort/sort-common/src/main/java/org/apache/inlong/sort/protocol/transformation/FunctionParam.java
+++ b/inlong-sort/sort-common/src/main/java/org/apache/inlong/sort/protocol/transformation/FunctionParam.java
@@ -22,6 +22,7 @@ import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonSub
import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.apache.inlong.sort.protocol.BuiltInFieldInfo;
import org.apache.inlong.sort.protocol.FieldInfo;
+import org.apache.inlong.sort.protocol.transformation.function.CascadeFunctionWrapper;
import org.apache.inlong.sort.protocol.transformation.function.HopEndFunction;
import org.apache.inlong.sort.protocol.transformation.function.HopFunction;
import org.apache.inlong.sort.protocol.transformation.function.HopStartFunction;
@@ -92,7 +93,8 @@ import org.apache.inlong.sort.protocol.transformation.operator.OrOperator;
@JsonSubTypes.Type(value = MultiValueFilterFunction.class, name = "multiValueFilter"),
@JsonSubTypes.Type(value = SplitIndexFunction.class, name = "splitIndex"),
@JsonSubTypes.Type(value = RegexpReplaceFunction.class, name = "regexpReplace"),
- @JsonSubTypes.Type(value = RegexpReplaceFirstFunction.class, name = "regexpReplaceFirst")
+ @JsonSubTypes.Type(value = RegexpReplaceFirstFunction.class, name = "regexpReplaceFirst"),
+ @JsonSubTypes.Type(value = CascadeFunctionWrapper.class, name = "cascadeFunctionWrapper")
})
public interface FunctionParam {
diff --git a/inlong-sort/sort-common/src/test/java/org/apache/inlong/sort/protocol/transformation/function/CascadeFunctionWrapperTest.java b/inlong-sort/sort-common/src/test/java/org/apache/inlong/sort/protocol/transformation/function/CascadeFunctionWrapperTest.java
new file mode 100644
index 000000000..b42386d21
--- /dev/null
+++ b/inlong-sort/sort-common/src/test/java/org/apache/inlong/sort/protocol/transformation/function/CascadeFunctionWrapperTest.java
@@ -0,0 +1,51 @@
+/*
+ * 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.sort.protocol.transformation.function;
+
+import org.apache.inlong.sort.formats.common.StringFormatInfo;
+import org.apache.inlong.sort.protocol.FieldInfo;
+import org.apache.inlong.sort.protocol.transformation.Function;
+import org.apache.inlong.sort.protocol.transformation.FunctionBaseTest;
+import org.apache.inlong.sort.protocol.transformation.StringConstantParam;
+
+import java.util.Arrays;
+
+/**
+ * Test for {@link CascadeFunctionWrapper}
+ */
+public class CascadeFunctionWrapperTest extends FunctionBaseTest {
+
+ @Override
+ public Function getTestObject() {
+ return new CascadeFunctionWrapper(
+ Arrays.asList(
+ new RegexpReplaceFirstFunction(new FieldInfo("replace_field", new StringFormatInfo()),
+ new StringConstantParam("replace_str"),
+ new StringConstantParam("target_str")),
+ new RegexpReplaceFunction(new FieldInfo("replace_field", new StringFormatInfo()),
+ new StringConstantParam("replace_str"),
+ new StringConstantParam("target_str"))
+ ));
+ }
+
+ @Override
+ public String getExpectFormat() {
+ return "REGEXP_REPLACE(REGEXP_REPLACE_FIRST(`replace_field`, 'replace_str', 'target_str'), "
+ + "'replace_str', 'target_str')";
+ }
+}