You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@paimon.apache.org by "zhangjun0x01 (via GitHub)" <gi...@apache.org> on 2023/08/15 13:22:45 UTC

[GitHub] [incubator-paimon] zhangjun0x01 opened a new pull request, #1822: [flink] refactor update data fields process function

zhangjun0x01 opened a new pull request, #1822:
URL: https://github.com/apache/incubator-paimon/pull/1822

   <!-- Please specify the module before the PR name: [core] ... or [flink] ... -->
   
   ### Purpose
   
   <!-- Linking this pull request to the issue -->
   
   
   Extract some common code
   
   <!-- What is the purpose of the change -->
   
   ### Tests
   
   <!-- List UT and IT cases to verify this change -->
   
   ### API and Format
   
   <!-- Does this change affect API or storage format -->
   
   ### Documentation
   
   <!-- Does this change introduce a new feature -->
   


-- 
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: issues-unsubscribe@paimon.apache.org

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


[GitHub] [incubator-paimon] yuzelin commented on a diff in pull request #1822: [flink] refactor update data fields process function

Posted by "yuzelin (via GitHub)" <gi...@apache.org>.
yuzelin commented on code in PR #1822:
URL: https://github.com/apache/incubator-paimon/pull/1822#discussion_r1295348775


##########
paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/sink/cdc/UpdatedDataFieldsBaseProcessFunction.java:
##########
@@ -0,0 +1,176 @@
+/*
+ * 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.paimon.flink.sink.cdc;
+
+import org.apache.paimon.catalog.Catalog;
+import org.apache.paimon.catalog.Identifier;
+import org.apache.paimon.schema.SchemaChange;
+import org.apache.paimon.schema.SchemaManager;
+import org.apache.paimon.schema.TableSchema;
+import org.apache.paimon.types.DataType;
+import org.apache.paimon.types.DataTypeChecks;
+import org.apache.paimon.types.DataTypeRoot;
+import org.apache.paimon.utils.Preconditions;
+
+import org.apache.flink.streaming.api.functions.ProcessFunction;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Arrays;
+import java.util.List;
+
+/** Base class for update data fields process function. */
+public abstract class UpdatedDataFieldsBaseProcessFunction<I, O> extends ProcessFunction<I, O> {

Review Comment:
   1. `UpdatedDataFieldsBaseProcessFunction` -> `UpdatedDataFieldsProcessFunctionBase`
   2. Some methods can be moved to this class: `Open`, `Close`.
   3. Some common codes can be refactored and placed to this class: 
   `UpdatedDataFieldsProcessFunction#getSchemaChanges` is static method and used by `MultiTableUpdatedDataFieldsProcessFunction`.



##########
paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/sink/cdc/MultiTableUpdatedDataFieldsProcessFunction.java:
##########
@@ -53,16 +47,17 @@
  * be 1.
  */
 public class MultiTableUpdatedDataFieldsProcessFunction
-        extends ProcessFunction<Tuple2<Identifier, List<DataField>>, Void> {
+        extends UpdatedDataFieldsBaseProcessFunction<Tuple2<Identifier, List<DataField>>, Void> {
 
     private static final Logger LOG =
             LoggerFactory.getLogger(MultiTableUpdatedDataFieldsProcessFunction.class);
 
     private final Map<Identifier, SchemaManager> schemaManagers = new HashMap<>();
-    private Catalog catalog;
+
     private final Catalog.Loader catalogLoader;
 
     public MultiTableUpdatedDataFieldsProcessFunction(Catalog.Loader catalogLoader) {
+        super(catalogLoader);
         this.catalogLoader = catalogLoader;

Review Comment:
   delete `this.catalogLoader = catalogLoader`



##########
paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/sink/cdc/UpdatedDataFieldsProcessFunction.java:
##########
@@ -50,23 +44,21 @@
  * <p>NOTE: To avoid concurrent schema changes, the parallelism of this {@link ProcessFunction} must
  * be 1.
  */
-public class UpdatedDataFieldsProcessFunction extends ProcessFunction<List<DataField>, Void> {
+public class UpdatedDataFieldsProcessFunction
+        extends UpdatedDataFieldsBaseProcessFunction<List<DataField>, Void> {
 
     private static final Logger LOG =

Review Comment:
   LOG is not used any more, can be deleted.



-- 
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: issues-unsubscribe@paimon.apache.org

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


[GitHub] [incubator-paimon] zhangjun0x01 commented on a diff in pull request #1822: [flink] refactor update data fields process function

Posted by "zhangjun0x01 (via GitHub)" <gi...@apache.org>.
zhangjun0x01 commented on code in PR #1822:
URL: https://github.com/apache/incubator-paimon/pull/1822#discussion_r1295366323


##########
paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/sink/cdc/MultiTableUpdatedDataFieldsProcessFunction.java:
##########
@@ -53,16 +47,17 @@
  * be 1.
  */
 public class MultiTableUpdatedDataFieldsProcessFunction
-        extends ProcessFunction<Tuple2<Identifier, List<DataField>>, Void> {
+        extends UpdatedDataFieldsBaseProcessFunction<Tuple2<Identifier, List<DataField>>, Void> {
 
     private static final Logger LOG =
             LoggerFactory.getLogger(MultiTableUpdatedDataFieldsProcessFunction.class);
 
     private final Map<Identifier, SchemaManager> schemaManagers = new HashMap<>();
-    private Catalog catalog;
+
     private final Catalog.Loader catalogLoader;
 
     public MultiTableUpdatedDataFieldsProcessFunction(Catalog.Loader catalogLoader) {
+        super(catalogLoader);
         this.catalogLoader = catalogLoader;

Review Comment:
   thanks for your suggestion, addressed it 



-- 
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: issues-unsubscribe@paimon.apache.org

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


[GitHub] [incubator-paimon] yuzelin merged pull request #1822: [flink] refactor update data fields process function

Posted by "yuzelin (via GitHub)" <gi...@apache.org>.
yuzelin merged PR #1822:
URL: https://github.com/apache/incubator-paimon/pull/1822


-- 
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: issues-unsubscribe@paimon.apache.org

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