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

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


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

commit a11d6d664f84cea5f0365f0e36ffed848e37bd88
Author: shee <[email protected]>
AuthorDate: Fri Sep 12 15:02:56 2025 +0800

    [Bug](rollup) fix type cast failed for stream load (#55558)
    
    ### What problem does this PR solve?
    
    Issue Number: close #xxx
    
    cherry-pick #55551
    
    Related PR: #xxx
    
    Problem Summary:
    
    ### Release note
    
    None
    
    ### Check List (For Author)
    
    - Test <!-- At least one of them must be included. -->
        - [ ] Regression test
        - [ ] Unit Test
        - [ ] Manual test (add detailed scripts or steps below)
        - [ ] No need to test or manual test. Explain why:
    - [ ] This is a refactor/code format and no logic has been changed.
            - [ ] Previous test can cover this change.
            - [ ] No code files have been changed.
            - [ ] Other reason <!-- Add your reason?  -->
    
    - Behavior changed:
        - [ ] No.
        - [ ] Yes. <!-- Explain the behavior change -->
    
    - Does this need documentation?
        - [ ] No.
    - [ ] Yes. <!-- Add document PR link here. eg:
    https://github.com/apache/doris-website/pull/1214 -->
    
    ### Check List (For Reviewer who merge this PR)
    
    - [ ] Confirm the release note
    - [ ] Confirm test cases
    - [ ] Confirm document
    - [ ] Add branch pick label <!-- Add branch pick label that this PR
    should merge into -->
    
    Co-authored-by: garenshi <[email protected]>
---
 .../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 553c0065a25..b1ed4c11500 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;
@@ -113,7 +114,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;
@@ -2922,7 +2922,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());
         }
@@ -3107,8 +3107,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);
@@ -3116,7 +3116,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;
@@ -3137,6 +3137,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 0778459d0b1..9f80759f7a2 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
@@ -176,6 +176,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