hailin0 commented on code in PR #8438:
URL: https://github.com/apache/seatunnel/pull/8438#discussion_r1904194588


##########
seatunnel-transforms-v2/src/test/java/org/apache/seatunnel/transform/sql/SQLTransformTest.java:
##########
@@ -282,4 +290,110 @@ public void testEscapeIdentifier() {
                 BasicType.STRING_TYPE, 
tableSchema.getColumns().get(1).getDataType());
         Assertions.assertEquals("a", result.get(0).getField(1));
     }
+
+    @Test
+    public void testSchemaChange() {
+        CatalogTable catalogTable =
+                CatalogTable.of(
+                        TableIdentifier.of(TEST_NAME, TEST_NAME, null, 
TEST_NAME),
+                        TableSchema.builder()
+                                .column(
+                                        PhysicalColumn.of(
+                                                "f1",
+                                                BasicType.LONG_TYPE,
+                                                null,
+                                                null,
+                                                false,
+                                                null,
+                                                null))
+                                .column(
+                                        PhysicalColumn.of(
+                                                "f2",
+                                                BasicType.LONG_TYPE,
+                                                null,
+                                                null,
+                                                true,
+                                                null,
+                                                null))
+                                .column(
+                                        PhysicalColumn.of(
+                                                "f3",
+                                                BasicType.LONG_TYPE,
+                                                null,
+                                                null,
+                                                true,
+                                                null,
+                                                null))
+                                .primaryKey(PrimaryKey.of("pk1", 
Arrays.asList("f1")))
+                                .constraintKey(
+                                        ConstraintKey.of(
+                                                
ConstraintKey.ConstraintType.UNIQUE_KEY,
+                                                "uk1",
+                                                Arrays.asList(
+                                                        
ConstraintKey.ConstraintKeyColumn.of(
+                                                                "f2",
+                                                                
ConstraintKey.ColumnSortType.ASC),
+                                                        
ConstraintKey.ConstraintKeyColumn.of(
+                                                                "f3",
+                                                                
ConstraintKey.ColumnSortType.ASC))))
+                                .build(),
+                        Collections.emptyMap(),
+                        Collections.singletonList("f2"),
+                        null);
+
+        AlterTableAddColumnEvent addColumnEvent =
+                AlterTableAddColumnEvent.add(
+                        catalogTable.getTableId(),
+                        PhysicalColumn.of("f4", BasicType.LONG_TYPE, null, 
null, true, null, null));
+        AlterTableModifyColumnEvent modifyColumnEvent =
+                AlterTableModifyColumnEvent.modify(
+                        catalogTable.getTableId(),
+                        PhysicalColumn.of("f4", BasicType.INT_TYPE, null, 
null, true, null, null));
+        AlterTableChangeColumnEvent changeColumnEvent =
+                AlterTableChangeColumnEvent.change(
+                        catalogTable.getTableId(),
+                        "f4",
+                        PhysicalColumn.of("f5", BasicType.INT_TYPE, null, 
null, true, null, null));
+        AlterTableDropColumnEvent dropColumnEvent =
+                new AlterTableDropColumnEvent(catalogTable.getTableId(), "f5");
+        ReadonlyConfig config =
+                ReadonlyConfig.fromMap(
+                        new HashMap<String, Object>() {
+                            {
+                                put("query", "select * from dual");
+                            }
+                        });
+
+        SQLTransform transform = new SQLTransform(config, catalogTable);

Review Comment:
   testcase flow:
   
   ```
   table: id<int>, name<string>, age<int>
   
   map(row) // row<1,a,18>
   mapSchemaChangeEvent(add-column) // add f1 int
   map(row) // row<1,a,18, 100>
   check output-row & output-event & table-schema
   
   mapSchemaChangeEvent(rename-column) // rename age f2 int
   map(row) // row<1,a,18, 100>
   check output-row & output-event & table-schema
   
   mapSchemaChangeEvent(update-column) // change f2 f2 string
   map(row) // row<1,a,a, 100>
   check output-row & output-event & table-schema
   
   mapSchemaChangeEvent(drop-column) // drop f2
   map(row) // row<1,a, 100>
   check data & table-schema
   
   ```



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