yuxiqian commented on code in PR #3804:
URL: https://github.com/apache/flink-cdc/pull/3804#discussion_r1888029795


##########
flink-cdc-cli/src/main/java/org/apache/flink/cdc/cli/parser/YamlPipelineDefinitionParser.java:
##########
@@ -78,6 +78,8 @@ public class YamlPipelineDefinitionParser implements 
PipelineDefinitionParser {
     private static final String TRANSFORM_PROJECTION_KEY = "projection";
     private static final String TRANSFORM_FILTER_KEY = "filter";
     private static final String TRANSFORM_DESCRIPTION_KEY = "description";
+    private static final String TRANSFORM_CONVERTOR_AFTER_TRANSFORM_KEY =

Review Comment:
   Seems "converter" is used more



##########
flink-cdc-cli/src/main/java/org/apache/flink/cdc/cli/parser/YamlPipelineDefinitionParser.java:
##########
@@ -316,6 +318,10 @@ private TransformDef toTransformDef(JsonNode 
transformNode) {
                 
Optional.ofNullable(transformNode.get(TRANSFORM_DESCRIPTION_KEY))
                         .map(JsonNode::asText)
                         .orElse(null);
+        String convertorAfterTransform =
+                
Optional.ofNullable(transformNode.get(TRANSFORM_CONVERTOR_AFTER_TRANSFORM_KEY))
+                        .map(JsonNode::asText)
+                        .orElse(null);

Review Comment:
   Is is possible to make this a list, so users can apply more than one 
converters sequentially?



##########
flink-cdc-cli/src/main/java/org/apache/flink/cdc/cli/parser/YamlPipelineDefinitionParser.java:
##########
@@ -316,6 +318,10 @@ private TransformDef toTransformDef(JsonNode 
transformNode) {
                 
Optional.ofNullable(transformNode.get(TRANSFORM_DESCRIPTION_KEY))
                         .map(JsonNode::asText)
                         .orElse(null);
+        String convertorAfterTransform =
+                
Optional.ofNullable(transformNode.get(TRANSFORM_CONVERTOR_AFTER_TRANSFORM_KEY))

Review Comment:
   What about naming this option "post-transform converters"? It's reasonable 
since it does take effect in `PostTransform` operator.



##########
flink-cdc-runtime/src/main/java/org/apache/flink/cdc/runtime/operators/transform/convertor/TransformConvertor.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.flink.cdc.runtime.operators.transform.convertor;
+
+import org.apache.flink.cdc.common.event.DataChangeEvent;
+import org.apache.flink.cdc.common.utils.StringUtils;
+import org.apache.flink.cdc.runtime.operators.transform.PostTransformOperator;
+import org.apache.flink.cdc.runtime.operators.transform.TransformRule;
+
+import java.io.Serializable;
+import java.util.Optional;
+
+/**
+ * The TransformConvertor applies to convert the {@link DataChangeEvent} after 
other part of {@link
+ * TransformRule} in {@link PostTransformOperator}.
+ */
+public interface TransformConvertor extends Serializable {

Review Comment:
   If users are supposed to write their own converters, this interface should 
be moved to `flink-cdc-common` and be marked with `@PublicEvolving`.



##########
flink-cdc-runtime/src/main/java/org/apache/flink/cdc/runtime/operators/transform/convertor/TransformConvertor.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.flink.cdc.runtime.operators.transform.convertor;
+
+import org.apache.flink.cdc.common.event.DataChangeEvent;
+import org.apache.flink.cdc.common.utils.StringUtils;
+import org.apache.flink.cdc.runtime.operators.transform.PostTransformOperator;
+import org.apache.flink.cdc.runtime.operators.transform.TransformRule;
+
+import java.io.Serializable;
+import java.util.Optional;
+
+/**
+ * The TransformConvertor applies to convert the {@link DataChangeEvent} after 
other part of {@link
+ * TransformRule} in {@link PostTransformOperator}.
+ */
+public interface TransformConvertor extends Serializable {
+    String SOFT_DELETE_CONVERTOR = "SOFT_DELETE";

Review Comment:
   Will it be cleaner if we separate interfaces and static enums? Just like we 
have `DataType` as an abstract base class, and `DataTypes` to collect all 
instantiated types. Mixing them together is a little messy.



##########
flink-cdc-runtime/src/main/java/org/apache/flink/cdc/runtime/operators/transform/convertor/TransformConvertor.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.flink.cdc.runtime.operators.transform.convertor;
+
+import org.apache.flink.cdc.common.event.DataChangeEvent;
+import org.apache.flink.cdc.common.utils.StringUtils;
+import org.apache.flink.cdc.runtime.operators.transform.PostTransformOperator;
+import org.apache.flink.cdc.runtime.operators.transform.TransformRule;
+
+import java.io.Serializable;
+import java.util.Optional;
+
+/**
+ * The TransformConvertor applies to convert the {@link DataChangeEvent} after 
other part of {@link
+ * TransformRule} in {@link PostTransformOperator}.
+ */
+public interface TransformConvertor extends Serializable {
+    String SOFT_DELETE_CONVERTOR = "SOFT_DELETE";
+
+    Optional<DataChangeEvent> convert(DataChangeEvent dataChangeEvent);
+
+    static Optional<TransformConvertor> of(String classPath) {
+        if (StringUtils.isNullOrWhitespaceOnly(classPath)) {
+            return Optional.empty();
+        }
+
+        if (SOFT_DELETE_CONVERTOR.equals(classPath)) {
+            return Optional.of(new SoftDeleteConvertor());
+        }

Review Comment:
   Seems allowing users to register converters in a similar way like UDFs and 
models in YAML `pipeline:` scope would be cleaner.



##########
flink-cdc-cli/src/main/java/org/apache/flink/cdc/cli/parser/YamlPipelineDefinitionParser.java:
##########
@@ -316,6 +318,10 @@ private TransformDef toTransformDef(JsonNode 
transformNode) {
                 
Optional.ofNullable(transformNode.get(TRANSFORM_DESCRIPTION_KEY))
                         .map(JsonNode::asText)
                         .orElse(null);
+        String convertorAfterTransform =

Review Comment:
   Docs need to be updated for this new option



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to