You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by "hailin0 (via GitHub)" <gi...@apache.org> on 2024/08/22 11:03:17 UTC

[PR] [Improve][CDC] Improve cdc task state restore for zeta [seatunnel]

hailin0 opened a new pull request, #7463:
URL: https://github.com/apache/seatunnel/pull/7463

   <!--
   
   Thank you for contributing to SeaTunnel! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   ## Contribution Checklist
     - Make sure that the pull request corresponds to a [GITHUB issue](https://github.com/apache/seatunnel/issues).
     - Name the pull request in the form "[Feature] [component] Title of the pull request", where *Feature* can be replaced by `Hotfix`, `Bug`, etc.
     - Minor fixes should be named following this pattern: `[hotfix] [docs] Fix typo in README.md doc`.
   -->
   
   ### Purpose of this pull request
   
   [Improve][CDC] Improve cdc task state restore for zeta
   
   ### Does this PR introduce _any_ user-facing change?
   
   No
   
   
   ### How was this patch tested?
   
   Already exists
   
   
   ### Check list
   
   * [ ] If any new Jar binary package adding in your PR, please add License Notice according
     [New License Guide](https://github.com/apache/seatunnel/blob/dev/docs/en/contribution/new-license.md)
   * [ ] If necessary, please update the documentation to describe the new feature. https://github.com/apache/seatunnel/tree/dev/docs
   * [ ] If you are contributing the connector code, please check that the following files are updated:
     1. Update [plugin-mapping.properties](https://github.com/apache/seatunnel/blob/dev/plugin-mapping.properties) and add new connector information in it
     2. Update the pom file of [seatunnel-dist](https://github.com/apache/seatunnel/blob/dev/seatunnel-dist/pom.xml)
     3. Add ci label in [label-scope-conf](https://github.com/apache/seatunnel/blob/dev/.github/workflows/labeler/label-scope-conf.yml)
     4. Add e2e testcase in [seatunnel-e2e](https://github.com/apache/seatunnel/tree/dev/seatunnel-e2e/seatunnel-connector-v2-e2e/)
     5. Update connector [plugin_config](https://github.com/apache/seatunnel/blob/dev/config/plugin_config)
   * [ ] Update the [`release-note`](https://github.com/apache/seatunnel/blob/dev/release-note.md).


-- 
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@seatunnel.apache.org

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


Re: [PR] [Improve][CDC] Improve cdc task state restore for zeta [seatunnel]

Posted by "dailai (via GitHub)" <gi...@apache.org>.
dailai commented on code in PR #7463:
URL: https://github.com/apache/seatunnel/pull/7463#discussion_r1730926627


##########
seatunnel-api/src/main/java/org/apache/seatunnel/api/sink/SupportSchemaEvolutionSinkWriter.java:
##########
@@ -0,0 +1,33 @@
+/*
+ * 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.seatunnel.api.sink;
+
+import org.apache.seatunnel.api.table.schema.event.SchemaChangeEvent;
+
+import java.io.IOException;
+
+public interface SupportSchemaEvolutionSinkWriter {

Review Comment:
   Should this interface extend SinkWriter to reduce the amount of interface for the implementing class.



-- 
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@seatunnel.apache.org

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


Re: [PR] [Improve][CDC] Improve cdc task state restore for zeta [seatunnel]

Posted by "hailin0 (via GitHub)" <gi...@apache.org>.
hailin0 commented on code in PR #7463:
URL: https://github.com/apache/seatunnel/pull/7463#discussion_r1732989710


##########
seatunnel-api/src/main/java/org/apache/seatunnel/api/sink/SupportSchemaEvolutionSinkWriter.java:
##########
@@ -0,0 +1,33 @@
+/*
+ * 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.seatunnel.api.sink;
+
+import org.apache.seatunnel.api.table.schema.event.SchemaChangeEvent;
+
+import java.io.IOException;
+
+public interface SupportSchemaEvolutionSinkWriter {

Review Comment:
   DDL should have an independent interface, and the connector can choose to support it, and use test cases to detect whether the user has implemented it correctly.
   
   https://github.com/apache/seatunnel/pull/7463/files/4d062ebcfa9fabf37aff535280874dc1443cb30c#diff-4e38101d35f3d5901ed61ddd52530609bc8facb2d1e41476a981b18b3b2ffb9cR198
   
   
   Other than that, I don't think of a better way. Using extends classes is more difficult to maintain.



-- 
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@seatunnel.apache.org

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


Re: [PR] [Improve][CDC] Improve cdc task state restore for zeta [seatunnel]

Posted by "dailai (via GitHub)" <gi...@apache.org>.
dailai commented on code in PR #7463:
URL: https://github.com/apache/seatunnel/pull/7463#discussion_r1730933687


##########
seatunnel-api/src/main/java/org/apache/seatunnel/api/sink/multitablesink/MultiTableSink.java:
##########
@@ -164,4 +168,13 @@ public List<TablePath> getSinkTables() {
     public void setJobContext(JobContext jobContext) {
         sinks.values().forEach(sink -> sink.setJobContext(jobContext));
     }
+
+    @Override
+    public List<SchemaChangeType> supports() {
+        SeaTunnelSink firstSink = sinks.entrySet().iterator().next().getValue();

Review Comment:
   The sink Action may include different kinds of sink, if the first sink that do not support SupportSchemaEvolutionSink and other support?



##########
seatunnel-api/src/main/java/org/apache/seatunnel/api/sink/multitablesink/MultiTableSink.java:
##########
@@ -164,4 +168,13 @@ public List<TablePath> getSinkTables() {
     public void setJobContext(JobContext jobContext) {
         sinks.values().forEach(sink -> sink.setJobContext(jobContext));
     }
+
+    @Override
+    public List<SchemaChangeType> supports() {
+        SeaTunnelSink firstSink = sinks.entrySet().iterator().next().getValue();

Review Comment:
   The sink action may include different kinds of sink, if the first sink that do not support SupportSchemaEvolutionSink and other support?



-- 
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@seatunnel.apache.org

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


Re: [PR] [Improve][CDC] Improve cdc task state restore for zeta [seatunnel]

Posted by "hailin0 (via GitHub)" <gi...@apache.org>.
hailin0 commented on PR #7463:
URL: https://github.com/apache/seatunnel/pull/7463#issuecomment-2312915282

   > It seem lack test case. Shall we add some? For example, read updated/deleted column data to unsupported transform/sink, what's will happen? And read table -> savepoint -> update column -> restore? I think the change will solve the problem of this scenario. But we need test case.
   
   Adding test cases later


-- 
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@seatunnel.apache.org

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


Re: [PR] [Improve][CDC] Improve cdc task state restore for zeta [seatunnel]

Posted by "hailin0 (via GitHub)" <gi...@apache.org>.
hailin0 commented on code in PR #7463:
URL: https://github.com/apache/seatunnel/pull/7463#discussion_r1818434095


##########
seatunnel-api/src/main/java/org/apache/seatunnel/api/sink/SinkWriter.java:
##########
@@ -52,6 +52,7 @@ public interface SinkWriter<T, CommitInfoT, StateT> {
      * @param event
      * @throws IOException
      */
+    @Deprecated

Review Comment:
   fixed



-- 
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@seatunnel.apache.org

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


Re: [PR] [Feature][Core] Support cdc task ddl restore for zeta [seatunnel]

Posted by "hailin0 (via GitHub)" <gi...@apache.org>.
hailin0 commented on code in PR #7463:
URL: https://github.com/apache/seatunnel/pull/7463#discussion_r1840323295


##########
seatunnel-api/src/main/java/org/apache/seatunnel/api/table/catalog/TableSchema.java:
##########
@@ -20,25 +20,37 @@
 import org.apache.seatunnel.api.table.type.SeaTunnelDataType;
 import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
 
-import lombok.AllArgsConstructor;
+import lombok.AccessLevel;
 import lombok.Data;
+import lombok.Getter;
 
 import java.io.Serializable;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 import java.util.stream.Collectors;
 
 /** Represent a physical table schema. */
 @Data
-@AllArgsConstructor
 public final class TableSchema implements Serializable {
     private static final long serialVersionUID = 1L;
     private final List<Column> columns;

Review Comment:
   fixed



-- 
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@seatunnel.apache.org

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


Re: [PR] [Improve][CDC] Improve cdc task state restore for zeta [seatunnel]

Posted by "hailin0 (via GitHub)" <gi...@apache.org>.
hailin0 commented on code in PR #7463:
URL: https://github.com/apache/seatunnel/pull/7463#discussion_r1732980705


##########
seatunnel-api/src/main/java/org/apache/seatunnel/api/sink/multitablesink/MultiTableSink.java:
##########
@@ -164,4 +168,13 @@ public List<TablePath> getSinkTables() {
     public void setJobContext(JobContext jobContext) {
         sinks.values().forEach(sink -> sink.setJobContext(jobContext));
     }
+
+    @Override
+    public List<SchemaChangeType> supports() {
+        SeaTunnelSink firstSink = sinks.entrySet().iterator().next().getValue();

Review Comment:
   For MultiTableSink it should only contain sinks of the same kind
   cc @Hisoka-X 



-- 
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@seatunnel.apache.org

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


Re: [PR] [Improve][CDC] Improve cdc task state restore for zeta [seatunnel]

Posted by "Carl-Zhou-CN (via GitHub)" <gi...@apache.org>.
Carl-Zhou-CN commented on PR #7463:
URL: https://github.com/apache/seatunnel/pull/7463#issuecomment-2325735855

   @hailin0 hi, I think this part needs a design to help me understand the whole process


-- 
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@seatunnel.apache.org

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


Re: [PR] [Feature][CDC] Support cdc task ddl restore for zeta [seatunnel]

Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #7463:
URL: https://github.com/apache/seatunnel/pull/7463#discussion_r1819970827


##########
seatunnel-engine/seatunnel-engine-client/src/main/java/org/apache/seatunnel/engine/client/job/ClientJobExecutionEnvironment.java:
##########
@@ -99,13 +100,21 @@ public ClientJobExecutionEnvironment(
     /** Search all jars in SEATUNNEL_HOME/plugins */
     @Override
     protected MultipleTableJobConfigParser getJobConfigParser() {
+        List<JobPipelineCheckpointData> pipelineCheckpoints = Collections.emptyList();
+        if (isStartWithSavePoint) {
+            LOGGER.info("Start with savepoint, load checkpoint state from job client");
+            pipelineCheckpoints =
+                    jobClient.getCheckpointData(
+                            Long.parseLong(jobConfig.getJobContext().getJobId()));
+        }

Review Comment:
   why we need get checkpoint states from server not from filesystem?



##########
seatunnel-api/src/main/java/org/apache/seatunnel/api/sink/multitablesink/MultiTableSink.java:
##########
@@ -164,4 +168,13 @@ public List<TablePath> getSinkTables() {
     public void setJobContext(JobContext jobContext) {
         sinks.values().forEach(sink -> sink.setJobContext(jobContext));
     }
+
+    @Override
+    public List<SchemaChangeType> supports() {
+        SeaTunnelSink firstSink = sinks.entrySet().iterator().next().getValue();

Review Comment:
   > For MultiTableSink it should only contain sinks of the same kind
   
   Right for now.



-- 
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@seatunnel.apache.org

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


Re: [PR] [Feature][CDC] Support cdc task ddl restore for zeta [seatunnel]

Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #7463:
URL: https://github.com/apache/seatunnel/pull/7463#discussion_r1819973236


##########
seatunnel-engine/seatunnel-engine-client/src/main/java/org/apache/seatunnel/engine/client/job/ClientJobExecutionEnvironment.java:
##########
@@ -99,13 +100,21 @@ public ClientJobExecutionEnvironment(
     /** Search all jars in SEATUNNEL_HOME/plugins */
     @Override
     protected MultipleTableJobConfigParser getJobConfigParser() {
+        List<JobPipelineCheckpointData> pipelineCheckpoints = Collections.emptyList();
+        if (isStartWithSavePoint) {
+            LOGGER.info("Start with savepoint, load checkpoint state from job client");
+            pipelineCheckpoints =
+                    jobClient.getCheckpointData(
+                            Long.parseLong(jobConfig.getJobContext().getJobId()));
+        }

Review Comment:
   oh, I got it. The checkpoint state stored by server.



-- 
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@seatunnel.apache.org

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


Re: [PR] [Feature][CDC] Support cdc task ddl restore for zeta [seatunnel]

Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #7463:
URL: https://github.com/apache/seatunnel/pull/7463#discussion_r1819970827


##########
seatunnel-engine/seatunnel-engine-client/src/main/java/org/apache/seatunnel/engine/client/job/ClientJobExecutionEnvironment.java:
##########
@@ -99,13 +100,21 @@ public ClientJobExecutionEnvironment(
     /** Search all jars in SEATUNNEL_HOME/plugins */
     @Override
     protected MultipleTableJobConfigParser getJobConfigParser() {
+        List<JobPipelineCheckpointData> pipelineCheckpoints = Collections.emptyList();
+        if (isStartWithSavePoint) {
+            LOGGER.info("Start with savepoint, load checkpoint state from job client");
+            pipelineCheckpoints =
+                    jobClient.getCheckpointData(
+                            Long.parseLong(jobConfig.getJobContext().getJobId()));
+        }

Review Comment:
   why we need get checkpoint states from server not from filesystem directly?



-- 
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@seatunnel.apache.org

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


Re: [PR] [Improve][CDC] Improve cdc task state restore for zeta [seatunnel]

Posted by "dailai (via GitHub)" <gi...@apache.org>.
dailai commented on code in PR #7463:
URL: https://github.com/apache/seatunnel/pull/7463#discussion_r1730933687


##########
seatunnel-api/src/main/java/org/apache/seatunnel/api/sink/multitablesink/MultiTableSink.java:
##########
@@ -164,4 +168,13 @@ public List<TablePath> getSinkTables() {
     public void setJobContext(JobContext jobContext) {
         sinks.values().forEach(sink -> sink.setJobContext(jobContext));
     }
+
+    @Override
+    public List<SchemaChangeType> supports() {
+        SeaTunnelSink firstSink = sinks.entrySet().iterator().next().getValue();

Review Comment:
   The sink Action may include a variety of different kinds of Sink, if the first Sink that do not support SupportSchemaEvolutionSink and other support?



-- 
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@seatunnel.apache.org

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


Re: [PR] [Feature][Core] Support cdc task ddl restore for zeta [seatunnel]

Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #7463:
URL: https://github.com/apache/seatunnel/pull/7463#discussion_r1840117354


##########
seatunnel-api/src/main/java/org/apache/seatunnel/api/table/catalog/TableSchema.java:
##########
@@ -20,25 +20,37 @@
 import org.apache.seatunnel.api.table.type.SeaTunnelDataType;
 import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
 
-import lombok.AllArgsConstructor;
+import lombok.AccessLevel;
 import lombok.Data;
+import lombok.Getter;
 
 import java.io.Serializable;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 import java.util.stream.Collectors;
 
 /** Represent a physical table schema. */
 @Data
-@AllArgsConstructor
 public final class TableSchema implements Serializable {
     private static final long serialVersionUID = 1L;
     private final List<Column> columns;

Review Comment:
   Sadly, the columns will be changed in other place, for example: https://github.com/apache/seatunnel/blob/97a1b00e481d23314a9b498556653ab34d8764c7/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/sink/AbstractJdbcSinkWriter.java#L92
   It will let columns and columnNames size not match.



-- 
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@seatunnel.apache.org

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


Re: [PR] [Improve][CDC] Improve cdc task ddl restore for zeta [seatunnel]

Posted by "hailin0 (via GitHub)" <gi...@apache.org>.
hailin0 commented on code in PR #7463:
URL: https://github.com/apache/seatunnel/pull/7463#discussion_r1818483508


##########
seatunnel-api/src/main/java/org/apache/seatunnel/api/table/factory/ChangeStreamTableSourceFactory.java:
##########
@@ -0,0 +1,115 @@
+/*
+ * 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.seatunnel.api.table.factory;
+
+import org.apache.seatunnel.api.serialization.DefaultSerializer;
+import org.apache.seatunnel.api.serialization.Serializer;
+import org.apache.seatunnel.api.source.SeaTunnelSource;
+import org.apache.seatunnel.api.source.SourceSplit;
+import org.apache.seatunnel.api.table.connector.TableSource;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+public interface ChangeStreamTableSourceFactory extends TableSourceFactory {

Review Comment:
   e.g. CDC/MQ Source The factory can be used to restore the source state from the checkpoint



-- 
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@seatunnel.apache.org

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


Re: [PR] [Improve][CDC] Improve cdc task ddl restore for zeta [seatunnel]

Posted by "hailin0 (via GitHub)" <gi...@apache.org>.
hailin0 commented on PR #7463:
URL: https://github.com/apache/seatunnel/pull/7463#issuecomment-2440719355

   > @hailin0 hi, I think this part needs a design to help me understand the whole process
   
   cc @Carl-Zhou-CN
   
   https://github.com/apache/seatunnel/issues/7930


-- 
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@seatunnel.apache.org

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


Re: [PR] [Feature][Core] Support cdc task ddl restore for zeta [seatunnel]

Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X merged PR #7463:
URL: https://github.com/apache/seatunnel/pull/7463


-- 
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@seatunnel.apache.org

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


Re: [PR] [Feature][Core] Support cdc task ddl restore for zeta [seatunnel]

Posted by "Carl-Zhou-CN (via GitHub)" <gi...@apache.org>.
Carl-Zhou-CN commented on PR #7463:
URL: https://github.com/apache/seatunnel/pull/7463#issuecomment-2475155642

   > > @hailin0 hi, I think this part needs a design to help me understand the whole process
   > 
   > cc @Carl-Zhou-CN
   > 
   > #7930
   
   He is great


-- 
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@seatunnel.apache.org

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


Re: [PR] [Improve][CDC] Improve cdc task state restore for zeta [seatunnel]

Posted by "Hisoka-X (via GitHub)" <gi...@apache.org>.
Hisoka-X commented on code in PR #7463:
URL: https://github.com/apache/seatunnel/pull/7463#discussion_r1729947862


##########
seatunnel-api/src/main/java/org/apache/seatunnel/api/table/factory/ChangeStreamTableSourceFactory.java:
##########
@@ -0,0 +1,115 @@
+/*
+ * 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.seatunnel.api.table.factory;
+
+import org.apache.seatunnel.api.serialization.DefaultSerializer;
+import org.apache.seatunnel.api.serialization.Serializer;
+import org.apache.seatunnel.api.source.SeaTunnelSource;
+import org.apache.seatunnel.api.source.SourceSplit;
+import org.apache.seatunnel.api.table.connector.TableSource;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+public interface ChangeStreamTableSourceFactory extends TableSourceFactory {

Review Comment:
   What's meaning of `ChangeStreamTable`? CDC?
   Any introduce of why we should add this?



##########
seatunnel-api/src/main/java/org/apache/seatunnel/api/sink/SinkWriter.java:
##########
@@ -52,6 +52,7 @@ public interface SinkWriter<T, CommitInfoT, StateT> {
      * @param event
      * @throws IOException
      */
+    @Deprecated

Review Comment:
   Please update the comment for instead interface.



-- 
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@seatunnel.apache.org

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


Re: [PR] [Improve][CDC] Improve cdc task ddl restore for zeta [seatunnel]

Posted by "hailin0 (via GitHub)" <gi...@apache.org>.
hailin0 commented on code in PR #7463:
URL: https://github.com/apache/seatunnel/pull/7463#discussion_r1818483508


##########
seatunnel-api/src/main/java/org/apache/seatunnel/api/table/factory/ChangeStreamTableSourceFactory.java:
##########
@@ -0,0 +1,115 @@
+/*
+ * 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.seatunnel.api.table.factory;
+
+import org.apache.seatunnel.api.serialization.DefaultSerializer;
+import org.apache.seatunnel.api.serialization.Serializer;
+import org.apache.seatunnel.api.source.SeaTunnelSource;
+import org.apache.seatunnel.api.source.SourceSplit;
+import org.apache.seatunnel.api.table.connector.TableSource;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+public interface ChangeStreamTableSourceFactory extends TableSourceFactory {

Review Comment:
   e.g. CDC/MQ Source The factory can be used to restore the source from the checkpoint



-- 
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@seatunnel.apache.org

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


Re: [PR] [Feature][Core] Support cdc task ddl restore for zeta [seatunnel]

Posted by "dailai (via GitHub)" <gi...@apache.org>.
dailai commented on PR #7463:
URL: https://github.com/apache/seatunnel/pull/7463#issuecomment-2453750553

   > LGTM. cc @dailai for a look
   
   Waiting to merge #7908 


-- 
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@seatunnel.apache.org

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


Re: [PR] [Feature][Core] Support cdc task ddl restore for zeta [seatunnel]

Posted by "hailin0 (via GitHub)" <gi...@apache.org>.
hailin0 commented on code in PR #7463:
URL: https://github.com/apache/seatunnel/pull/7463#discussion_r1838331005


##########
seatunnel-connectors-v2/connector-cdc/connector-cdc-base/src/main/java/org/apache/seatunnel/connectors/cdc/debezium/ConnectTableChangeSerializer.java:
##########
@@ -0,0 +1,233 @@
+/*
+ * 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.seatunnel.connectors.cdc.debezium;
+
+import org.apache.kafka.connect.data.Schema;
+import org.apache.kafka.connect.data.SchemaBuilder;
+import org.apache.kafka.connect.data.Struct;
+
+import io.debezium.relational.Column;
+import io.debezium.relational.ColumnEditor;
+import io.debezium.relational.Table;
+import io.debezium.relational.TableId;
+import io.debezium.relational.history.TableChanges;
+import io.debezium.util.SchemaNameAdjuster;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.StreamSupport;
+
+import static io.debezium.relational.history.ConnectTableChangeSerializer.AUTO_INCREMENTED_KEY;
+import static io.debezium.relational.history.ConnectTableChangeSerializer.CHARSET_NAME_KEY;
+import static io.debezium.relational.history.ConnectTableChangeSerializer.COLUMNS_KEY;
+import static io.debezium.relational.history.ConnectTableChangeSerializer.COMMENT_KEY;
+import static io.debezium.relational.history.ConnectTableChangeSerializer.DEFAULT_CHARSET_NAME_KEY;
+import static io.debezium.relational.history.ConnectTableChangeSerializer.GENERATED_KEY;
+import static io.debezium.relational.history.ConnectTableChangeSerializer.ID_KEY;
+import static io.debezium.relational.history.ConnectTableChangeSerializer.JDBC_TYPE_KEY;
+import static io.debezium.relational.history.ConnectTableChangeSerializer.LENGTH_KEY;
+import static io.debezium.relational.history.ConnectTableChangeSerializer.NAME_KEY;
+import static io.debezium.relational.history.ConnectTableChangeSerializer.NATIVE_TYPE_KEY;
+import static io.debezium.relational.history.ConnectTableChangeSerializer.OPTIONAL_KEY;
+import static io.debezium.relational.history.ConnectTableChangeSerializer.POSITION_KEY;
+import static io.debezium.relational.history.ConnectTableChangeSerializer.PRIMARY_KEY_COLUMN_NAMES_KEY;
+import static io.debezium.relational.history.ConnectTableChangeSerializer.SCALE_KEY;
+import static io.debezium.relational.history.ConnectTableChangeSerializer.TABLE_KEY;
+import static io.debezium.relational.history.ConnectTableChangeSerializer.TYPE_EXPRESSION_KEY;
+import static io.debezium.relational.history.ConnectTableChangeSerializer.TYPE_KEY;
+import static io.debezium.relational.history.ConnectTableChangeSerializer.TYPE_NAME_KEY;
+
+/**
+ * A serializer for {@link TableChanges} that deserialize the table list of {@link Struct} into a
+ * {@link TableChanges}. This class is used to deserialize the checkpoint data into {@link
+ * TableChanges}.
+ */
+public class ConnectTableChangeSerializer
+        implements TableChanges.TableChangesSerializer<List<Struct>>, Serializable {
+    private static final String ENUM_VALUES_KEY = "enumValues";
+    private static final SchemaNameAdjuster SCHEMA_NAME_ADJUSTER = SchemaNameAdjuster.create();
+
+    private static final Schema COLUMN_SCHEMA =
+            SchemaBuilder.struct()
+                    .name(SCHEMA_NAME_ADJUSTER.adjust("io.debezium.connector.schema.Column"))
+                    .field(NAME_KEY, Schema.STRING_SCHEMA)
+                    .field(JDBC_TYPE_KEY, Schema.INT32_SCHEMA)
+                    .field(NATIVE_TYPE_KEY, Schema.OPTIONAL_INT32_SCHEMA)
+                    .field(TYPE_NAME_KEY, Schema.STRING_SCHEMA)
+                    .field(TYPE_EXPRESSION_KEY, Schema.OPTIONAL_STRING_SCHEMA)
+                    .field(CHARSET_NAME_KEY, Schema.OPTIONAL_STRING_SCHEMA)
+                    .field(LENGTH_KEY, Schema.OPTIONAL_INT32_SCHEMA)
+                    .field(SCALE_KEY, Schema.OPTIONAL_INT32_SCHEMA)
+                    .field(POSITION_KEY, Schema.INT32_SCHEMA)
+                    .field(OPTIONAL_KEY, Schema.OPTIONAL_BOOLEAN_SCHEMA)
+                    .field(AUTO_INCREMENTED_KEY, Schema.OPTIONAL_BOOLEAN_SCHEMA)
+                    .field(GENERATED_KEY, Schema.OPTIONAL_BOOLEAN_SCHEMA)
+                    .field(COMMENT_KEY, Schema.OPTIONAL_STRING_SCHEMA)
+                    .field(
+                            ENUM_VALUES_KEY,
+                            SchemaBuilder.array(Schema.STRING_SCHEMA).optional().build())
+                    .build();
+
+    public static final Schema TABLE_SCHEMA =
+            SchemaBuilder.struct()
+                    .name(SCHEMA_NAME_ADJUSTER.adjust("io.debezium.connector.schema.Table"))
+                    .field(DEFAULT_CHARSET_NAME_KEY, Schema.OPTIONAL_STRING_SCHEMA)
+                    .field(
+                            PRIMARY_KEY_COLUMN_NAMES_KEY,
+                            SchemaBuilder.array(Schema.STRING_SCHEMA).optional().build())
+                    .field(COLUMNS_KEY, SchemaBuilder.array(COLUMN_SCHEMA).build())
+                    .field(COMMENT_KEY, Schema.OPTIONAL_STRING_SCHEMA)
+                    .build();
+
+    public static final Schema CHANGE_SCHEMA =
+            SchemaBuilder.struct()
+                    .name(SCHEMA_NAME_ADJUSTER.adjust("io.debezium.connector.schema.Change"))
+                    .field(TYPE_KEY, Schema.STRING_SCHEMA)
+                    .field(ID_KEY, Schema.STRING_SCHEMA)
+                    .field(TABLE_KEY, TABLE_SCHEMA)
+                    .build();
+
+    @Override
+    public List<Struct> serialize(TableChanges tableChanges) {
+        return StreamSupport.stream(tableChanges.spliterator(), false)
+                .map(this::toStruct)
+                .collect(Collectors.toList());
+    }
+
+    @Override
+    public TableChanges deserialize(List<Struct> data, boolean useCatalogBeforeSchema) {
+        TableChanges tableChanges = new TableChanges();
+        for (Struct struct : data) {
+            String tableId = struct.getString(ID_KEY);
+            TableChanges.TableChangeType changeType =
+                    TableChanges.TableChangeType.valueOf(struct.getString(TYPE_KEY));
+            Table table = toTable(struct.getStruct(TABLE_KEY), TableId.parse(tableId));
+            switch (changeType) {
+                case CREATE:
+                    tableChanges.create(table);
+                    break;
+                case DROP:
+                    tableChanges.drop(table);
+                    break;
+                case ALTER:
+                    tableChanges.alter(table);
+                    break;
+                default:
+                    throw new IllegalArgumentException("Unknown table change type: " + changeType);
+            }
+        }
+        return tableChanges;
+    }
+
+    public Table toTable(Struct struct, TableId tableId) {
+        return Table.editor()
+                .tableId(tableId)
+                .setDefaultCharsetName(struct.getString(DEFAULT_CHARSET_NAME_KEY))
+                .setPrimaryKeyNames(struct.getArray(PRIMARY_KEY_COLUMN_NAMES_KEY))
+                .setColumns(
+                        struct.getArray(COLUMNS_KEY).stream()
+                                .map(Struct.class::cast)
+                                .map(this::toColumn)
+                                .collect(Collectors.toList()))
+                .create();
+    }
+
+    private Column toColumn(Struct struct) {
+        ColumnEditor editor =
+                Column.editor()
+                        .name(struct.getString(NAME_KEY))
+                        .jdbcType(struct.getInt32(JDBC_TYPE_KEY))
+                        .type(
+                                struct.getString(TYPE_NAME_KEY),
+                                struct.getString(TYPE_EXPRESSION_KEY))
+                        .charsetName(struct.getString(CHARSET_NAME_KEY))
+                        .position(struct.getInt32(POSITION_KEY))
+                        .optional(struct.getBoolean(OPTIONAL_KEY))
+                        .autoIncremented(struct.getBoolean(AUTO_INCREMENTED_KEY))
+                        .generated(struct.getBoolean(GENERATED_KEY));
+        if (struct.get(NATIVE_TYPE_KEY) != null) {
+            editor.nativeType(struct.getInt32(NATIVE_TYPE_KEY));
+        }
+        if (struct.get(LENGTH_KEY) != null) {
+            editor.length(struct.getInt32(LENGTH_KEY));
+        }
+        if (struct.get(SCALE_KEY) != null) {
+            editor.scale(struct.getInt32(SCALE_KEY));
+        }
+        if (struct.get(COMMENT_KEY) != null) {
+            editor.comment(struct.getString(COMMENT_KEY));
+        }
+        if (struct.get(ENUM_VALUES_KEY) != null) {
+            editor.enumValues(struct.getArray(ENUM_VALUES_KEY));

Review Comment:
   close #8030



-- 
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@seatunnel.apache.org

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