Hisoka-X commented on code in PR #9020:
URL: https://github.com/apache/seatunnel/pull/9020#discussion_r2006776595


##########
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:
   why we should add column with nullable is true then update column to set 
nullable to false? Why not direct add column with nullable is false?



##########
seatunnel-connectors-v2/connector-paimon/src/test/java/org/apache/seatunnel/connectors/seatunnel/paimon/utils/RowTypeConverterTest.java:
##########
@@ -189,7 +189,7 @@ public void before() {
                 PhysicalColumn.builder()
                         .name("c_decimal")
                         .sourceType(DataTypes.DECIMAL(30, 8).toString())
-                        .nullable(false)
+                        .nullable(true)

Review Comment:
   Let's cover both true and false scenarios.



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