yuxiqian commented on code in PR #3323: URL: https://github.com/apache/flink-cdc/pull/3323#discussion_r1623725867
########## flink-cdc-connect/flink-cdc-pipeline-connectors/flink-cdc-pipeline-connector-paimon/src/main/java/org/apache/flink/cdc/connectors/paimon/sink/PaimonMetadataApplier.java: ########## @@ -129,25 +133,113 @@ private void applyCreateTable(CreateTableEvent event) private void applyAddColumn(AddColumnEvent event) throws Catalog.TableNotExistException, Catalog.ColumnAlreadyExistException, Catalog.ColumnNotExistException { - List<SchemaChange> tableChangeList = new ArrayList<>(); - event.getAddedColumns() - .forEach( - (column) -> { - SchemaChange tableChange = - SchemaChange.addColumn( - column.getAddColumn().getName(), - LogicalTypeConversion.toDataType( - DataTypeUtils.toFlinkDataType( - column.getAddColumn().getType()) - .getLogicalType())); - tableChangeList.add(tableChange); - }); + List<SchemaChange> tableChangeList = applyAddColumnEventWithPosition(event); catalog.alterTable( new Identifier(event.tableId().getSchemaName(), event.tableId().getTableName()), tableChangeList, true); } + private List<SchemaChange> applyAddColumnEventWithPosition(AddColumnEvent event) + throws Catalog.TableNotExistException { + List<SchemaChange> tableChangeList = new ArrayList<>(); + for (AddColumnEvent.ColumnWithPosition columnWithPosition : event.getAddedColumns()) { + SchemaChange tableChange; + switch (columnWithPosition.getPosition()) { + case FIRST: + tableChange = + SchemaChange.addColumn( Review Comment: What about declaring `applyAddColumnWithFirstPosition` and `applyAddColumnWithAfterPosition` too for consistency? And maybe we can extract some sharing logic (like column name, data conversion, and comments) to reduce code duplication. -- 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: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org