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:
```
map(row)
mapSchemaChangeEvent(add-column)
map(row)
check output-row & output-event & table-schema
mapSchemaChangeEvent(rename-column)
map(row)
check output-row & output-event & table-schema
mapSchemaChangeEvent(update-column)
map(row)
check output-row & output-event & table-schema
mapSchemaChangeEvent(drop-column)
map(row)
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]