hawk9821 commented on code in PR #9020: URL: https://github.com/apache/seatunnel/pull/9020#discussion_r2007706191
########## seatunnel-connectors-v2/connector-paimon/src/main/java/org/apache/seatunnel/connectors/seatunnel/paimon/sink/schema/handler/AlterPaimonTableSchemaEventHandler.java: ########## @@ -95,13 +98,16 @@ private void applySingleSchemaChangeEvent(SchemaChangeEvent event) { ? null : SchemaChange.Move.after(column.getName(), afterColumnName); BasicTypeDefine<DataType> reconvertColumn = PaimonTypeMapper.INSTANCE.reconvert(column); - SchemaChange schemaChange = + DataType nativeType = reconvertColumn.getNativeType(); + List<SchemaChange> schemaChanges = new ArrayList<>(); + schemaChanges.add( SchemaChange.addColumn( - column.getName(), - reconvertColumn.getNativeType(), - column.getComment(), - move); - paimonCatalog.alterTable(identifier, schemaChange, false); + column.getName(), nativeType.copy(true), column.getComment(), move)); + if (!nativeType.isNullable()) { + schemaChanges.add( + SchemaChange.updateColumnType(column.getName(), nativeType.copy(false))); + } + paimonCatalog.alterTable(identifier, schemaChanges, false); Review Comment: add column cannot specify NOT NULL ``` SchemaChange addColumn1 = SchemaChange.addColumn("add_column3", DataTypes.STRING().copy(false)); throw execption Caused by: java.lang.IllegalArgumentException: Column add_column3 cannot specify NOT NULL in the mysql_to_paimon.products table. at org.apache.paimon.utils.Preconditions.checkArgument(Preconditions.java:149) at org.apache.paimon.schema.SchemaManager.commitChanges(SchemaManager.java:333) at org.apache.paimon.catalog.FileSystemCatalog.alterTableImpl(FileSystemCatalog.java:146) at org.apache.paimon.catalog.AbstractCatalog.alterTable(AbstractCatalog.java:375) at org.apache.paimon.catalog.DelegateCatalog.alterTable(DelegateCatalog.java:119) at org.apache.paimon.catalog.CachingCatalog.alterTable(CachingCatalog.java:223) at com.hawk.paimon.AlterTableColumn.main(AlterTableColumn.java:24) ``` -- 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-unsubscr...@seatunnel.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org