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 2023/07/20 09:35:23 UTC

[GitHub] [seatunnel] hailin0 opened a new pull request, #5125: [Feature][CDC][Zeta] Support schema evolution framework(DDL)

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

   <!--
   
   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
   
   subtask of https://github.com/apache/seatunnel/issues/4672
   
   ## Check list
   
   * [ ] Code changed are covered with tests, or it does not need tests for reason:
   * [ ] 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 change log that in connector document. For more details you can refer to [connector-v2](https://github.com/apache/seatunnel/tree/dev/docs/en/connector-v2)
     2. Update [plugin-mapping.properties](https://github.com/apache/seatunnel/blob/dev/plugin-mapping.properties) and add new connector information in it
     3. Update the pom file of [seatunnel-dist](https://github.com/apache/seatunnel/blob/dev/seatunnel-dist/pom.xml)
   * [ ] 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


[GitHub] [seatunnel] hailin0 commented on a diff in pull request #5125: [Feature][CDC][Zeta] Support schema evolution framework(DDL)

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


##########
seatunnel-api/src/main/java/org/apache/seatunnel/api/table/event/handler/AlterTableEventHandler.java:
##########
@@ -0,0 +1,196 @@
+/*
+ * 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.event.handler;
+
+import org.apache.seatunnel.api.table.catalog.Column;
+import org.apache.seatunnel.api.table.event.AlterTableAddColumnEvent;
+import org.apache.seatunnel.api.table.event.AlterTableChangeColumnEvent;
+import org.apache.seatunnel.api.table.event.AlterTableColumnEvent;
+import org.apache.seatunnel.api.table.event.AlterTableColumnsEvent;
+import org.apache.seatunnel.api.table.event.AlterTableDropColumnEvent;
+import org.apache.seatunnel.api.table.event.AlterTableEvent;
+import org.apache.seatunnel.api.table.event.AlterTableModifyColumnEvent;
+import org.apache.seatunnel.api.table.event.AlterTableNameEvent;
+import org.apache.seatunnel.api.table.event.SchemaChangeEvent;
+import org.apache.seatunnel.api.table.type.SeaTunnelDataType;
+import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
+
+public class AlterTableEventHandler implements DataTypeChangeEventHandler {
+    private SeaTunnelRowType dataType;
+
+    @Override
+    public SeaTunnelRowType get() {
+        return dataType;
+    }
+
+    @Override
+    public DataTypeChangeEventHandler reset(SeaTunnelRowType dataType) {
+        this.dataType = dataType;
+        return this;
+    }
+
+    @Override
+    public SeaTunnelRowType apply(SchemaChangeEvent event) {
+        AlterTableEvent alterTableEvent = (AlterTableEvent) event;
+        return apply(dataType, alterTableEvent);
+    }
+
+    private SeaTunnelRowType apply(SeaTunnelRowType dataType, AlterTableEvent alterTableEvent) {
+        if (alterTableEvent instanceof AlterTableNameEvent) {
+            return dataType;
+        }
+        if (alterTableEvent instanceof AlterTableDropColumnEvent) {
+            return applyDropColumn(dataType, (AlterTableDropColumnEvent) alterTableEvent);
+        }
+        if (alterTableEvent instanceof AlterTableModifyColumnEvent) {
+            return applyModifyColumn(dataType, (AlterTableModifyColumnEvent) alterTableEvent);
+        }
+        if (alterTableEvent instanceof AlterTableChangeColumnEvent) {
+            return applyChangeColumn(dataType, (AlterTableChangeColumnEvent) alterTableEvent);
+        }
+        if (alterTableEvent instanceof AlterTableAddColumnEvent) {
+            return applyAddColumn(dataType, (AlterTableAddColumnEvent) alterTableEvent);
+        }
+        if (alterTableEvent instanceof AlterTableColumnsEvent) {
+            SeaTunnelRowType newType = dataType;
+            for (AlterTableColumnEvent columnEvent :
+                    ((AlterTableColumnsEvent) alterTableEvent).getEvents()) {
+                newType = apply(newType, columnEvent);
+            }
+            return newType;
+        }
+
+        throw new UnsupportedOperationException(
+                "Unsupported alter table event: " + alterTableEvent);
+    }

Review Comment:
   switch unsupported  judgement object instanceof 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


[GitHub] [seatunnel] hailin0 commented on pull request #5125: [Feature][CDC][Zeta] Support schema evolution framework(DDL)

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

   <img width="1497" alt="image" src="https://github.com/apache/seatunnel/assets/14371345/1c0b39ef-deaa-4733-ae15-c937050d0454">
   


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


[GitHub] [seatunnel] TaoZex commented on a diff in pull request #5125: [Feature][CDC][Zeta] Support schema evolution framework(DDL)

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


##########
seatunnel-api/src/main/java/org/apache/seatunnel/api/table/event/handler/AlterTableEventHandler.java:
##########
@@ -0,0 +1,196 @@
+/*
+ * 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.event.handler;
+
+import org.apache.seatunnel.api.table.catalog.Column;
+import org.apache.seatunnel.api.table.event.AlterTableAddColumnEvent;
+import org.apache.seatunnel.api.table.event.AlterTableChangeColumnEvent;
+import org.apache.seatunnel.api.table.event.AlterTableColumnEvent;
+import org.apache.seatunnel.api.table.event.AlterTableColumnsEvent;
+import org.apache.seatunnel.api.table.event.AlterTableDropColumnEvent;
+import org.apache.seatunnel.api.table.event.AlterTableEvent;
+import org.apache.seatunnel.api.table.event.AlterTableModifyColumnEvent;
+import org.apache.seatunnel.api.table.event.AlterTableNameEvent;
+import org.apache.seatunnel.api.table.event.SchemaChangeEvent;
+import org.apache.seatunnel.api.table.type.SeaTunnelDataType;
+import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
+
+public class AlterTableEventHandler implements DataTypeChangeEventHandler {
+    private SeaTunnelRowType dataType;
+
+    @Override
+    public SeaTunnelRowType get() {
+        return dataType;
+    }
+
+    @Override
+    public DataTypeChangeEventHandler reset(SeaTunnelRowType dataType) {
+        this.dataType = dataType;
+        return this;
+    }
+
+    @Override
+    public SeaTunnelRowType apply(SchemaChangeEvent event) {
+        AlterTableEvent alterTableEvent = (AlterTableEvent) event;
+        return apply(dataType, alterTableEvent);
+    }
+
+    private SeaTunnelRowType apply(SeaTunnelRowType dataType, AlterTableEvent alterTableEvent) {
+        if (alterTableEvent instanceof AlterTableNameEvent) {
+            return dataType;
+        }
+        if (alterTableEvent instanceof AlterTableDropColumnEvent) {
+            return applyDropColumn(dataType, (AlterTableDropColumnEvent) alterTableEvent);
+        }
+        if (alterTableEvent instanceof AlterTableModifyColumnEvent) {
+            return applyModifyColumn(dataType, (AlterTableModifyColumnEvent) alterTableEvent);
+        }
+        if (alterTableEvent instanceof AlterTableChangeColumnEvent) {
+            return applyChangeColumn(dataType, (AlterTableChangeColumnEvent) alterTableEvent);
+        }
+        if (alterTableEvent instanceof AlterTableAddColumnEvent) {
+            return applyAddColumn(dataType, (AlterTableAddColumnEvent) alterTableEvent);
+        }
+        if (alterTableEvent instanceof AlterTableColumnsEvent) {
+            SeaTunnelRowType newType = dataType;
+            for (AlterTableColumnEvent columnEvent :
+                    ((AlterTableColumnsEvent) alterTableEvent).getEvents()) {
+                newType = apply(newType, columnEvent);
+            }
+            return newType;
+        }
+
+        throw new UnsupportedOperationException(
+                "Unsupported alter table event: " + alterTableEvent);
+    }

Review Comment:
   It's my mistake. Thanks for your reminding.



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


[GitHub] [seatunnel] hailin0 commented on pull request #5125: [Feature][CDC][Zeta] Support schema evolution framework(DDL)

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

   <img width="1496" alt="image" src="https://github.com/apache/seatunnel/assets/14371345/61a421bd-fdce-4a70-86ea-93a8b1ad067e">
   <img width="1496" alt="image" src="https://github.com/apache/seatunnel/assets/14371345/d4e59ec2-3904-4c45-adc7-3744ffc92269">
   


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


[GitHub] [seatunnel] Hisoka-X merged pull request #5125: [Feature][CDC][Zeta] Support schema evolution framework(DDL)

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


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


[GitHub] [seatunnel] TaoZex commented on a diff in pull request #5125: [Feature][CDC][Zeta] Support schema evolution framework(DDL)

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


##########
seatunnel-api/src/main/java/org/apache/seatunnel/api/table/event/handler/AlterTableEventHandler.java:
##########
@@ -0,0 +1,196 @@
+/*
+ * 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.event.handler;
+
+import org.apache.seatunnel.api.table.catalog.Column;
+import org.apache.seatunnel.api.table.event.AlterTableAddColumnEvent;
+import org.apache.seatunnel.api.table.event.AlterTableChangeColumnEvent;
+import org.apache.seatunnel.api.table.event.AlterTableColumnEvent;
+import org.apache.seatunnel.api.table.event.AlterTableColumnsEvent;
+import org.apache.seatunnel.api.table.event.AlterTableDropColumnEvent;
+import org.apache.seatunnel.api.table.event.AlterTableEvent;
+import org.apache.seatunnel.api.table.event.AlterTableModifyColumnEvent;
+import org.apache.seatunnel.api.table.event.AlterTableNameEvent;
+import org.apache.seatunnel.api.table.event.SchemaChangeEvent;
+import org.apache.seatunnel.api.table.type.SeaTunnelDataType;
+import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
+
+public class AlterTableEventHandler implements DataTypeChangeEventHandler {
+    private SeaTunnelRowType dataType;
+
+    @Override
+    public SeaTunnelRowType get() {
+        return dataType;
+    }
+
+    @Override
+    public DataTypeChangeEventHandler reset(SeaTunnelRowType dataType) {
+        this.dataType = dataType;
+        return this;
+    }
+
+    @Override
+    public SeaTunnelRowType apply(SchemaChangeEvent event) {
+        AlterTableEvent alterTableEvent = (AlterTableEvent) event;
+        return apply(dataType, alterTableEvent);
+    }
+
+    private SeaTunnelRowType apply(SeaTunnelRowType dataType, AlterTableEvent alterTableEvent) {
+        if (alterTableEvent instanceof AlterTableNameEvent) {
+            return dataType;
+        }
+        if (alterTableEvent instanceof AlterTableDropColumnEvent) {
+            return applyDropColumn(dataType, (AlterTableDropColumnEvent) alterTableEvent);
+        }
+        if (alterTableEvent instanceof AlterTableModifyColumnEvent) {
+            return applyModifyColumn(dataType, (AlterTableModifyColumnEvent) alterTableEvent);
+        }
+        if (alterTableEvent instanceof AlterTableChangeColumnEvent) {
+            return applyChangeColumn(dataType, (AlterTableChangeColumnEvent) alterTableEvent);
+        }
+        if (alterTableEvent instanceof AlterTableAddColumnEvent) {
+            return applyAddColumn(dataType, (AlterTableAddColumnEvent) alterTableEvent);
+        }
+        if (alterTableEvent instanceof AlterTableColumnsEvent) {
+            SeaTunnelRowType newType = dataType;
+            for (AlterTableColumnEvent columnEvent :
+                    ((AlterTableColumnsEvent) alterTableEvent).getEvents()) {
+                newType = apply(newType, columnEvent);
+            }
+            return newType;
+        }
+
+        throw new UnsupportedOperationException(
+                "Unsupported alter table event: " + alterTableEvent);
+    }

Review Comment:
   switch-case is recommended



##########
seatunnel-connectors-v2/connector-cdc/connector-cdc-base/src/main/java/org/apache/seatunnel/connectors/cdc/base/source/reader/IncrementalSourceRecordEmitter.java:
##########
@@ -110,9 +113,14 @@ protected void processElement(
             Offset watermark = getWatermark(element);
             if (isLowWatermarkEvent(element) && splitState.isSnapshotSplitState()) {
                 splitState.asSnapshotSplitState().setLowWatermark(watermark);
-            }
-            if (isHighWatermarkEvent(element) && splitState.isSnapshotSplitState()) {
+            } else if (isHighWatermarkEvent(element) && splitState.isSnapshotSplitState()) {
                 splitState.asSnapshotSplitState().setHighWatermark(watermark);
+            } else if (isSchemaChangeBeforeWatermarkEvent(element)
+                    && splitState.isIncrementalSplitState()) {
+                emitElement(element, output);
+            } else if (isSchemaChangeAfterWatermarkEvent(element)
+                    && splitState.isIncrementalSplitState()) {
+                emitElement(element, output);
             }
         } else if (isSchemaChangeEvent(element) && splitState.isIncrementalSplitState()) {
             emitElement(element, output);

Review Comment:
   Multiple else if statements can be combined into one



##########
seatunnel-api/src/main/java/org/apache/seatunnel/api/table/event/handler/AlterTableEventHandler.java:
##########
@@ -0,0 +1,196 @@
+/*
+ * 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.event.handler;
+
+import org.apache.seatunnel.api.table.catalog.Column;
+import org.apache.seatunnel.api.table.event.AlterTableAddColumnEvent;
+import org.apache.seatunnel.api.table.event.AlterTableChangeColumnEvent;
+import org.apache.seatunnel.api.table.event.AlterTableColumnEvent;
+import org.apache.seatunnel.api.table.event.AlterTableColumnsEvent;
+import org.apache.seatunnel.api.table.event.AlterTableDropColumnEvent;
+import org.apache.seatunnel.api.table.event.AlterTableEvent;
+import org.apache.seatunnel.api.table.event.AlterTableModifyColumnEvent;
+import org.apache.seatunnel.api.table.event.AlterTableNameEvent;
+import org.apache.seatunnel.api.table.event.SchemaChangeEvent;
+import org.apache.seatunnel.api.table.type.SeaTunnelDataType;
+import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
+
+public class AlterTableEventHandler implements DataTypeChangeEventHandler {
+    private SeaTunnelRowType dataType;
+
+    @Override
+    public SeaTunnelRowType get() {
+        return dataType;
+    }
+
+    @Override
+    public DataTypeChangeEventHandler reset(SeaTunnelRowType dataType) {
+        this.dataType = dataType;
+        return this;
+    }
+
+    @Override
+    public SeaTunnelRowType apply(SchemaChangeEvent event) {
+        AlterTableEvent alterTableEvent = (AlterTableEvent) event;
+        return apply(dataType, alterTableEvent);
+    }
+
+    private SeaTunnelRowType apply(SeaTunnelRowType dataType, AlterTableEvent alterTableEvent) {
+        if (alterTableEvent instanceof AlterTableNameEvent) {
+            return dataType;
+        }
+        if (alterTableEvent instanceof AlterTableDropColumnEvent) {
+            return applyDropColumn(dataType, (AlterTableDropColumnEvent) alterTableEvent);
+        }
+        if (alterTableEvent instanceof AlterTableModifyColumnEvent) {
+            return applyModifyColumn(dataType, (AlterTableModifyColumnEvent) alterTableEvent);
+        }
+        if (alterTableEvent instanceof AlterTableChangeColumnEvent) {
+            return applyChangeColumn(dataType, (AlterTableChangeColumnEvent) alterTableEvent);
+        }
+        if (alterTableEvent instanceof AlterTableAddColumnEvent) {
+            return applyAddColumn(dataType, (AlterTableAddColumnEvent) alterTableEvent);
+        }
+        if (alterTableEvent instanceof AlterTableColumnsEvent) {
+            SeaTunnelRowType newType = dataType;
+            for (AlterTableColumnEvent columnEvent :
+                    ((AlterTableColumnsEvent) alterTableEvent).getEvents()) {
+                newType = apply(newType, columnEvent);
+            }
+            return newType;
+        }
+
+        throw new UnsupportedOperationException(
+                "Unsupported alter table event: " + alterTableEvent);
+    }
+
+    private SeaTunnelRowType applyAddColumn(
+            SeaTunnelRowType dataType, AlterTableAddColumnEvent addColumnEvent) {
+        LinkedList<String> originFields = new LinkedList<>(Arrays.asList(dataType.getFieldNames()));
+        LinkedList<SeaTunnelDataType<?>> originFieldTypes =
+                new LinkedList<>(Arrays.asList(dataType.getFieldTypes()));
+        Column column = addColumnEvent.getColumn();
+        if (originFields.contains(column.getName())) {
+            return applyModifyColumn(
+                    dataType,
+                    new AlterTableModifyColumnEvent(
+                            addColumnEvent.tablePath(),
+                            addColumnEvent.getColumn(),
+                            addColumnEvent.isFirst(),
+                            addColumnEvent.getAfterColumn()));
+        }

Review Comment:
   How about using the apply method to judge it?



##########
seatunnel-engine/seatunnel-engine-common/src/main/java/org/apache/seatunnel/engine/common/config/server/CheckpointConfig.java:
##########
@@ -52,6 +54,13 @@ public void setCheckpointTimeout(long checkpointTimeout) {
         this.checkpointTimeout = checkpointTimeout;
     }
 
+    public void setSchemaChangeCheckpointTimeout(long checkpointTimeout) {
+        checkArgument(
+                checkpointTimeout >= MINIMAL_CHECKPOINT_TIME,
+                "The minimum checkpoint timeout is 10 mills.");

Review Comment:
   ```suggestion
                   "The minimum checkpoint timeout is 10 milliseconds.");
   ```



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


[GitHub] [seatunnel] hailin0 commented on a diff in pull request #5125: [Feature][CDC][Zeta] Support schema evolution framework(DDL)

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


##########
seatunnel-api/src/main/java/org/apache/seatunnel/api/table/event/handler/AlterTableEventHandler.java:
##########
@@ -0,0 +1,196 @@
+/*
+ * 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.event.handler;
+
+import org.apache.seatunnel.api.table.catalog.Column;
+import org.apache.seatunnel.api.table.event.AlterTableAddColumnEvent;
+import org.apache.seatunnel.api.table.event.AlterTableChangeColumnEvent;
+import org.apache.seatunnel.api.table.event.AlterTableColumnEvent;
+import org.apache.seatunnel.api.table.event.AlterTableColumnsEvent;
+import org.apache.seatunnel.api.table.event.AlterTableDropColumnEvent;
+import org.apache.seatunnel.api.table.event.AlterTableEvent;
+import org.apache.seatunnel.api.table.event.AlterTableModifyColumnEvent;
+import org.apache.seatunnel.api.table.event.AlterTableNameEvent;
+import org.apache.seatunnel.api.table.event.SchemaChangeEvent;
+import org.apache.seatunnel.api.table.type.SeaTunnelDataType;
+import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
+
+public class AlterTableEventHandler implements DataTypeChangeEventHandler {
+    private SeaTunnelRowType dataType;
+
+    @Override
+    public SeaTunnelRowType get() {
+        return dataType;
+    }
+
+    @Override
+    public DataTypeChangeEventHandler reset(SeaTunnelRowType dataType) {
+        this.dataType = dataType;
+        return this;
+    }
+
+    @Override
+    public SeaTunnelRowType apply(SchemaChangeEvent event) {
+        AlterTableEvent alterTableEvent = (AlterTableEvent) event;
+        return apply(dataType, alterTableEvent);
+    }
+
+    private SeaTunnelRowType apply(SeaTunnelRowType dataType, AlterTableEvent alterTableEvent) {
+        if (alterTableEvent instanceof AlterTableNameEvent) {
+            return dataType;
+        }
+        if (alterTableEvent instanceof AlterTableDropColumnEvent) {
+            return applyDropColumn(dataType, (AlterTableDropColumnEvent) alterTableEvent);
+        }
+        if (alterTableEvent instanceof AlterTableModifyColumnEvent) {
+            return applyModifyColumn(dataType, (AlterTableModifyColumnEvent) alterTableEvent);
+        }
+        if (alterTableEvent instanceof AlterTableChangeColumnEvent) {
+            return applyChangeColumn(dataType, (AlterTableChangeColumnEvent) alterTableEvent);
+        }
+        if (alterTableEvent instanceof AlterTableAddColumnEvent) {
+            return applyAddColumn(dataType, (AlterTableAddColumnEvent) alterTableEvent);
+        }
+        if (alterTableEvent instanceof AlterTableColumnsEvent) {
+            SeaTunnelRowType newType = dataType;
+            for (AlterTableColumnEvent columnEvent :
+                    ((AlterTableColumnsEvent) alterTableEvent).getEvents()) {
+                newType = apply(newType, columnEvent);
+            }
+            return newType;
+        }
+
+        throw new UnsupportedOperationException(
+                "Unsupported alter table event: " + alterTableEvent);
+    }
+
+    private SeaTunnelRowType applyAddColumn(
+            SeaTunnelRowType dataType, AlterTableAddColumnEvent addColumnEvent) {
+        LinkedList<String> originFields = new LinkedList<>(Arrays.asList(dataType.getFieldNames()));
+        LinkedList<SeaTunnelDataType<?>> originFieldTypes =
+                new LinkedList<>(Arrays.asList(dataType.getFieldTypes()));
+        Column column = addColumnEvent.getColumn();
+        if (originFields.contains(column.getName())) {
+            return applyModifyColumn(
+                    dataType,
+                    new AlterTableModifyColumnEvent(
+                            addColumnEvent.tablePath(),
+                            addColumnEvent.getColumn(),
+                            addColumnEvent.isFirst(),
+                            addColumnEvent.getAfterColumn()));
+        }

Review Comment:
   Here only the update column can be called, there are no other options



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


[GitHub] [seatunnel] hailin0 commented on pull request #5125: [Feature][CDC][Zeta] Support schema evolution framework(DDL)

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

   @EricJoy2048 PTAL


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


[GitHub] [seatunnel] hailin0 commented on pull request #5125: [Feature][CDC][Zeta] Support schema evolution framework(DDL)

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

   @MonsterChenzhuo 
   <img width="1107" alt="image" src="https://github.com/apache/seatunnel/assets/14371345/5c40e28f-8556-4e53-b22c-835f9a578639">
   


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


[GitHub] [seatunnel] TaoZex commented on a diff in pull request #5125: [Feature][CDC][Zeta] Support schema evolution framework(DDL)

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


##########
seatunnel-api/src/main/java/org/apache/seatunnel/api/table/event/handler/AlterTableEventHandler.java:
##########
@@ -0,0 +1,196 @@
+/*
+ * 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.event.handler;
+
+import org.apache.seatunnel.api.table.catalog.Column;
+import org.apache.seatunnel.api.table.event.AlterTableAddColumnEvent;
+import org.apache.seatunnel.api.table.event.AlterTableChangeColumnEvent;
+import org.apache.seatunnel.api.table.event.AlterTableColumnEvent;
+import org.apache.seatunnel.api.table.event.AlterTableColumnsEvent;
+import org.apache.seatunnel.api.table.event.AlterTableDropColumnEvent;
+import org.apache.seatunnel.api.table.event.AlterTableEvent;
+import org.apache.seatunnel.api.table.event.AlterTableModifyColumnEvent;
+import org.apache.seatunnel.api.table.event.AlterTableNameEvent;
+import org.apache.seatunnel.api.table.event.SchemaChangeEvent;
+import org.apache.seatunnel.api.table.type.SeaTunnelDataType;
+import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
+
+public class AlterTableEventHandler implements DataTypeChangeEventHandler {
+    private SeaTunnelRowType dataType;
+
+    @Override
+    public SeaTunnelRowType get() {
+        return dataType;
+    }
+
+    @Override
+    public DataTypeChangeEventHandler reset(SeaTunnelRowType dataType) {
+        this.dataType = dataType;
+        return this;
+    }
+
+    @Override
+    public SeaTunnelRowType apply(SchemaChangeEvent event) {
+        AlterTableEvent alterTableEvent = (AlterTableEvent) event;
+        return apply(dataType, alterTableEvent);
+    }
+
+    private SeaTunnelRowType apply(SeaTunnelRowType dataType, AlterTableEvent alterTableEvent) {
+        if (alterTableEvent instanceof AlterTableNameEvent) {
+            return dataType;
+        }
+        if (alterTableEvent instanceof AlterTableDropColumnEvent) {
+            return applyDropColumn(dataType, (AlterTableDropColumnEvent) alterTableEvent);
+        }
+        if (alterTableEvent instanceof AlterTableModifyColumnEvent) {
+            return applyModifyColumn(dataType, (AlterTableModifyColumnEvent) alterTableEvent);
+        }
+        if (alterTableEvent instanceof AlterTableChangeColumnEvent) {
+            return applyChangeColumn(dataType, (AlterTableChangeColumnEvent) alterTableEvent);
+        }
+        if (alterTableEvent instanceof AlterTableAddColumnEvent) {
+            return applyAddColumn(dataType, (AlterTableAddColumnEvent) alterTableEvent);
+        }
+        if (alterTableEvent instanceof AlterTableColumnsEvent) {
+            SeaTunnelRowType newType = dataType;
+            for (AlterTableColumnEvent columnEvent :
+                    ((AlterTableColumnsEvent) alterTableEvent).getEvents()) {
+                newType = apply(newType, columnEvent);
+            }
+            return newType;
+        }
+
+        throw new UnsupportedOperationException(
+                "Unsupported alter table event: " + alterTableEvent);
+    }

Review Comment:
   switch-case is recommended



##########
seatunnel-api/src/main/java/org/apache/seatunnel/api/table/event/handler/AlterTableEventHandler.java:
##########
@@ -0,0 +1,196 @@
+/*
+ * 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.event.handler;
+
+import org.apache.seatunnel.api.table.catalog.Column;
+import org.apache.seatunnel.api.table.event.AlterTableAddColumnEvent;
+import org.apache.seatunnel.api.table.event.AlterTableChangeColumnEvent;
+import org.apache.seatunnel.api.table.event.AlterTableColumnEvent;
+import org.apache.seatunnel.api.table.event.AlterTableColumnsEvent;
+import org.apache.seatunnel.api.table.event.AlterTableDropColumnEvent;
+import org.apache.seatunnel.api.table.event.AlterTableEvent;
+import org.apache.seatunnel.api.table.event.AlterTableModifyColumnEvent;
+import org.apache.seatunnel.api.table.event.AlterTableNameEvent;
+import org.apache.seatunnel.api.table.event.SchemaChangeEvent;
+import org.apache.seatunnel.api.table.type.SeaTunnelDataType;
+import org.apache.seatunnel.api.table.type.SeaTunnelRowType;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
+
+public class AlterTableEventHandler implements DataTypeChangeEventHandler {
+    private SeaTunnelRowType dataType;
+
+    @Override
+    public SeaTunnelRowType get() {
+        return dataType;
+    }
+
+    @Override
+    public DataTypeChangeEventHandler reset(SeaTunnelRowType dataType) {
+        this.dataType = dataType;
+        return this;
+    }
+
+    @Override
+    public SeaTunnelRowType apply(SchemaChangeEvent event) {
+        AlterTableEvent alterTableEvent = (AlterTableEvent) event;
+        return apply(dataType, alterTableEvent);
+    }
+
+    private SeaTunnelRowType apply(SeaTunnelRowType dataType, AlterTableEvent alterTableEvent) {
+        if (alterTableEvent instanceof AlterTableNameEvent) {
+            return dataType;
+        }
+        if (alterTableEvent instanceof AlterTableDropColumnEvent) {
+            return applyDropColumn(dataType, (AlterTableDropColumnEvent) alterTableEvent);
+        }
+        if (alterTableEvent instanceof AlterTableModifyColumnEvent) {
+            return applyModifyColumn(dataType, (AlterTableModifyColumnEvent) alterTableEvent);
+        }
+        if (alterTableEvent instanceof AlterTableChangeColumnEvent) {
+            return applyChangeColumn(dataType, (AlterTableChangeColumnEvent) alterTableEvent);
+        }
+        if (alterTableEvent instanceof AlterTableAddColumnEvent) {
+            return applyAddColumn(dataType, (AlterTableAddColumnEvent) alterTableEvent);
+        }
+        if (alterTableEvent instanceof AlterTableColumnsEvent) {
+            SeaTunnelRowType newType = dataType;
+            for (AlterTableColumnEvent columnEvent :
+                    ((AlterTableColumnsEvent) alterTableEvent).getEvents()) {
+                newType = apply(newType, columnEvent);
+            }
+            return newType;
+        }
+
+        throw new UnsupportedOperationException(
+                "Unsupported alter table event: " + alterTableEvent);
+    }

Review Comment:
   switch-case is recommended



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