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

yiguolei pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.1 by this push:
     new d7c017f0f9e [Bug](rollup) fix type cast failed for stream load (#55551)
d7c017f0f9e is described below

commit d7c017f0f9e22a626f44a939040add558dc2f4b9
Author: shee <[email protected]>
AuthorDate: Tue Sep 2 09:47:47 2025 +0800

    [Bug](rollup) fix type cast failed for stream load (#55551)
---
 .../apache/doris/alter/SchemaChangeHandler.java    | 22 +++++++++++++++++-----
 .../doris/catalog/MaterializedIndexMeta.java       |  6 ++++++
 2 files changed, 23 insertions(+), 5 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 7013e1a9615..5b9fbc2e19e 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
@@ -20,6 +20,7 @@ package org.apache.doris.alter;
 import org.apache.doris.analysis.AddColumnClause;
 import org.apache.doris.analysis.AddColumnsClause;
 import org.apache.doris.analysis.AlterClause;
+import org.apache.doris.analysis.Analyzer;
 import org.apache.doris.analysis.BuildIndexClause;
 import org.apache.doris.analysis.CancelAlterTableStmt;
 import org.apache.doris.analysis.CancelStmt;
@@ -110,7 +111,6 @@ import com.google.common.collect.Sets;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -2793,7 +2793,7 @@ public class SchemaChangeHandler extends AlterHandler {
         //update base index schema
         Map<Long, List<Column>> oldIndexSchemaMap = 
olapTable.getCopiedIndexIdToSchema(true);
         try {
-            updateBaseIndexSchema(olapTable, indexSchemaMap, indexes);
+            updateBaseIndexSchema(db, olapTable, indexSchemaMap, indexes);
         } catch (Exception e) {
             throw new DdlException(e.getMessage());
         }
@@ -2977,8 +2977,8 @@ public class SchemaChangeHandler extends AlterHandler {
         return changedIndexIdToSchema;
     }
 
-    public void updateBaseIndexSchema(OlapTable olapTable, Map<Long, 
LinkedList<Column>> indexSchemaMap,
-                                      List<Index> indexes) throws IOException {
+    public void updateBaseIndexSchema(Database db, OlapTable olapTable, 
Map<Long, LinkedList<Column>> indexSchemaMap,
+                                      List<Index> indexes) throws Exception {
         long baseIndexId = olapTable.getBaseIndexId();
         List<Long> indexIds = new ArrayList<Long>();
         indexIds.add(baseIndexId);
@@ -2986,7 +2986,7 @@ public class SchemaChangeHandler extends AlterHandler {
         for (int i = 0; i < indexIds.size(); i++) {
             List<Column> indexSchema = indexSchemaMap.get(indexIds.get(i));
             MaterializedIndexMeta currentIndexMeta = 
olapTable.getIndexMetaByIndexId(indexIds.get(i));
-            currentIndexMeta.setSchema(indexSchema);
+            currentIndexMeta.setSchema(indexSchema, 
createAnalyzer(db.getId()));
 
             int currentSchemaVersion = currentIndexMeta.getSchemaVersion();
             int newSchemaVersion = currentSchemaVersion + 1;
@@ -3007,6 +3007,18 @@ public class SchemaChangeHandler extends AlterHandler {
         olapTable.rebuildDistributionInfo();
     }
 
+    private Analyzer createAnalyzer(long dbId) throws AnalysisException {
+        ConnectContext connectContext = new ConnectContext();
+        Database db;
+        try {
+            db = Env.getCurrentInternalCatalog().getDbOrMetaException(dbId);
+        } catch (MetaNotFoundException e) {
+            throw new AnalysisException("error happens when create analyzer", 
e);
+        }
+        connectContext.setDatabase(db.getFullName());
+        return new Analyzer(Env.getCurrentEnv(), connectContext);
+    }
+
     public void 
replayModifyTableAddOrDropInvertedIndices(TableAddOrDropInvertedIndicesInfo 
info)
             throws MetaNotFoundException {
         if (LOG.isDebugEnabled()) {
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/catalog/MaterializedIndexMeta.java 
b/fe/fe-core/src/main/java/org/apache/doris/catalog/MaterializedIndexMeta.java
index 68cf52a9249..dc85c6962ea 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/catalog/MaterializedIndexMeta.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/catalog/MaterializedIndexMeta.java
@@ -172,6 +172,12 @@ public class MaterializedIndexMeta implements Writable, 
GsonPostProcessable {
         initColumnNameMap();
     }
 
+    public void setSchema(List<Column> newSchema, Analyzer analyzer) throws 
IOException {
+        this.schema = newSchema;
+        parseStmt(analyzer);
+        initColumnNameMap();
+    }
+
     public List<Column> getPrefixKeyColumns() {
         List<Column> keys = Lists.newArrayList();
         for (Column col : schema) {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to