diff --git a/fe/fe-core/src/main/java/org/apache/doris/binlog/BinlogManager.java b/fe/fe-core/src/main/java/org/apache/doris/binlog/BinlogManager.java index 6fc2e3f813fb07..3daad2a0ed9b58 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/binlog/BinlogManager.java +++ b/fe/fe-core/src/main/java/org/apache/doris/binlog/BinlogManager.java @@ -33,6 +33,7 @@ import org.apache.doris.persist.ReplacePartitionOperationLog; import org.apache.doris.persist.TableAddOrDropColumnsInfo; import org.apache.doris.persist.TableInfo; +import org.apache.doris.persist.TableRenameColumnInfo; import org.apache.doris.persist.TruncateTableInfo; import org.apache.doris.thrift.TBinlog; import org.apache.doris.thrift.TBinlogType; @@ -330,6 +331,17 @@ public void addTableRename(TableInfo info, long commitSeq) { addBinlog(dbId, tableIds, commitSeq, timestamp, type, data, false, info); } + public void addColumnRename(TableRenameColumnInfo info, long commitSeq) { + long dbId = info.getDbId(); + List tableIds = Lists.newArrayList(); + tableIds.add(info.getTableId()); + long timestamp = -1; + TBinlogType type = TBinlogType.RENAME_COLUMN; + String data = info.toJson(); + + addBinlog(dbId, tableIds, commitSeq, timestamp, type, data, false, info); + } + // get binlog by dbId, return first binlog.version > version public Pair getBinlog(long dbId, long tableId, long prevCommitSeq) { TStatus status = new TStatus(TStatusCode.OK); diff --git a/fe/fe-core/src/main/java/org/apache/doris/persist/EditLog.java b/fe/fe-core/src/main/java/org/apache/doris/persist/EditLog.java index 0e7dba0bba7659..dc6f43afee267e 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/persist/EditLog.java +++ b/fe/fe-core/src/main/java/org/apache/doris/persist/EditLog.java @@ -1576,7 +1576,9 @@ public void logPartitionRename(TableInfo tableInfo) { } public void logColumnRename(TableRenameColumnInfo info) { - logEdit(OperationType.OP_RENAME_COLUMN, info); + long logId = logEdit(OperationType.OP_RENAME_COLUMN, info); + LOG.info("log column rename, logId : {}, infos: {}", logId, info); + Env.getCurrentEnv().getBinlogManager().addColumnRename(info, logId); } public void logAddBroker(BrokerMgr.ModifyBrokerInfo info) { diff --git a/fe/fe-core/src/main/java/org/apache/doris/persist/TableRenameColumnInfo.java b/fe/fe-core/src/main/java/org/apache/doris/persist/TableRenameColumnInfo.java index eafdb943e1164b..1a9e21b776f659 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/persist/TableRenameColumnInfo.java +++ b/fe/fe-core/src/main/java/org/apache/doris/persist/TableRenameColumnInfo.java @@ -81,6 +81,10 @@ public static TableRenameColumnInfo read(DataInput in) throws IOException { return GsonUtils.GSON.fromJson(Text.readString(in), TableRenameColumnInfo.class); } + public String toJson() { + return GsonUtils.GSON.toJson(this); + } + @Override public boolean equals(Object obj) { if (obj == this) { diff --git a/gensrc/thrift/FrontendService.thrift b/gensrc/thrift/FrontendService.thrift index 9077dbd3cec2c8..3190d331851df5 100644 --- a/gensrc/thrift/FrontendService.thrift +++ b/gensrc/thrift/FrontendService.thrift @@ -1183,6 +1183,7 @@ enum TBinlogType { REPLACE_PARTITIONS = 12, TRUNCATE_TABLE = 13, RENAME_TABLE = 14, + RENAME_COLUMN = 15, } struct TBinlog {