This is an automated email from the ASF dual-hosted git repository.

gavinchou pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new b7ace78f998 [chore](persist) save base index id & index names in 
TableAddOrDropColumnsInfo (#47881)
b7ace78f998 is described below

commit b7ace78f998e4a8b42e3e8c761e59b4249d37921
Author: walter <maoch...@selectdb.com>
AuthorDate: Fri Feb 14 20:31:02 2025 +0800

    [chore](persist) save base index id & index names in 
TableAddOrDropColumnsInfo (#47881)
    
    Related PR: https://github.com/selectdb/ccr-syncer
---
 .../main/java/org/apache/doris/alter/SchemaChangeHandler.java |  6 ++++--
 .../org/apache/doris/persist/TableAddOrDropColumnsInfo.java   | 11 +++++++++--
 .../apache/doris/persist/TableAddOrDropColumnsInfoTest.java   |  8 ++++++--
 3 files changed, 19 insertions(+), 6 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java 
b/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java
index b27783feece..36fc30d5307 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java
@@ -2944,8 +2944,10 @@ public class SchemaChangeHandler extends AlterHandler {
                     olapTable.getName(), jobId, isReplay);
         } else {
             if (!isReplay) {
-                TableAddOrDropColumnsInfo info = new 
TableAddOrDropColumnsInfo(rawSql, db.getId(), olapTable.getId(),
-                        indexSchemaMap, oldIndexSchemaMap, indexes, jobId);
+                Map<String, Long> indexNameToId = new 
HashMap<>(olapTable.getIndexNameToId());
+                TableAddOrDropColumnsInfo info = new TableAddOrDropColumnsInfo(
+                        rawSql, db.getId(), olapTable.getId(), 
olapTable.getBaseIndexId(),
+                        indexSchemaMap, oldIndexSchemaMap, indexNameToId, 
indexes, jobId);
                 if (LOG.isDebugEnabled()) {
                     LOG.debug("logModifyTableAddOrDropColumns info:{}", info);
                 }
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/persist/TableAddOrDropColumnsInfo.java
 
b/fe/fe-core/src/main/java/org/apache/doris/persist/TableAddOrDropColumnsInfo.java
index 14b7187fac6..4b880c05096 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/persist/TableAddOrDropColumnsInfo.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/persist/TableAddOrDropColumnsInfo.java
@@ -40,10 +40,14 @@ public class TableAddOrDropColumnsInfo implements Writable {
     private long dbId;
     @SerializedName(value = "tableId")
     private long tableId;
+    @SerializedName(value = "baseIndexId")
+    private long baseIndexId; // only used for ccr, not included in equals
     @SerializedName(value = "indexSchemaMap")
     private Map<Long, LinkedList<Column>> indexSchemaMap;
     @SerializedName(value = "oldIndexSchemaMap")
-    private Map<Long, List<Column>> oldIndexSchemaMap;  // only used for ccr, 
not included in equals
+    private Map<Long, List<Column>> oldIndexSchemaMap; // only used for ccr, 
not included in equals
+    @SerializedName(value = "indexNameToId")
+    private Map<String, Long> indexNameToId; // only used for ccr, not 
included in equals
     @SerializedName(value = "indexes")
     private List<Index> indexes;
     @SerializedName(value = "jobId")
@@ -51,15 +55,18 @@ public class TableAddOrDropColumnsInfo implements Writable {
     @SerializedName(value = "rawSql")
     private String rawSql;
 
-    public TableAddOrDropColumnsInfo(String rawSql, long dbId, long tableId,
+    public TableAddOrDropColumnsInfo(String rawSql, long dbId, long tableId, 
long baseIndexId,
             Map<Long, LinkedList<Column>> indexSchemaMap,
             Map<Long, List<Column>> oldIndexSchemaMap,
+            Map<String, Long> indexNameToId,
             List<Index> indexes, long jobId) {
         this.rawSql = rawSql;
         this.dbId = dbId;
         this.tableId = tableId;
+        this.baseIndexId = baseIndexId;
         this.indexSchemaMap = indexSchemaMap;
         this.oldIndexSchemaMap = oldIndexSchemaMap;
+        this.indexNameToId = indexNameToId;
         this.indexes = indexes;
         this.jobId = jobId;
     }
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/persist/TableAddOrDropColumnsInfoTest.java
 
b/fe/fe-core/src/test/java/org/apache/doris/persist/TableAddOrDropColumnsInfoTest.java
index 4df2759e9df..da48a24c79f 100644
--- 
a/fe/fe-core/src/test/java/org/apache/doris/persist/TableAddOrDropColumnsInfoTest.java
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/persist/TableAddOrDropColumnsInfoTest.java
@@ -67,11 +67,15 @@ public class TableAddOrDropColumnsInfoTest {
         Map<Long, List<Column>> oldIndexSchemaMap = new HashMap<>();
         oldIndexSchemaMap.put(tableId, fullSchema);
 
+        Map<String, Long> indexNameToId = new HashMap<>();
+        indexNameToId.put("index", 1L);
+
         List<Index> indexes = Lists.newArrayList(
                 new Index(0, "index", Lists.newArrayList("testCol1"), 
IndexDef.IndexType.INVERTED, null, "xxxxxx", Lists.newArrayList(1)));
 
-        TableAddOrDropColumnsInfo tableAddOrDropColumnsInfo1 = new 
TableAddOrDropColumnsInfo("", dbId, tableId,
-                indexSchemaMap, oldIndexSchemaMap, indexes, jobId);
+        TableAddOrDropColumnsInfo tableAddOrDropColumnsInfo1 = new 
TableAddOrDropColumnsInfo(
+                "", dbId, tableId, tableId,
+                indexSchemaMap, oldIndexSchemaMap, indexNameToId, indexes, 
jobId);
 
         String c1Json = GsonUtils.GSON.toJson(tableAddOrDropColumnsInfo1);
         Text.writeString(out, c1Json);


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to