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

dataroaring 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 ffa5ac3fad9 [Bugfix] Fix mv column type is not changed when do schema 
change (#34598)
ffa5ac3fad9 is described below

commit ffa5ac3fad92cd007d4363027b4bbc721398b619
Author: Lightman <31928846+lchangli...@users.noreply.github.com>
AuthorDate: Mon May 27 14:46:33 2024 +0800

    [Bugfix] Fix mv column type is not changed when do schema change (#34598)
---
 .../apache/doris/alter/SchemaChangeHandler.java    |  63 +++++++------
 .../org/apache/doris/alter/SchemaChangeJobV2.java  |  48 +++++-----
 .../doris/analysis/CreateMaterializedViewStmt.java |   2 +-
 .../schema_change_modify_mv_column_type.out        | 103 +++++++++++++++++++++
 .../schema_change_modify_mv_column_type2.out       |  75 +++++++++++++++
 .../schema_change_modify_mv_column_type_agg.out    |  55 +++++++++++
 .../schema_change_modify_mv_column_type.groovy     |  98 ++++++++++++++++++++
 .../schema_change_modify_mv_column_type2.groovy    |  98 ++++++++++++++++++++
 .../schema_change_modify_mv_column_type_agg.groovy |  97 +++++++++++++++++++
 9 files changed, 582 insertions(+), 57 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 4a6fc3fd856..aa747a6d699 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
@@ -25,6 +25,7 @@ import org.apache.doris.analysis.CancelAlterTableStmt;
 import org.apache.doris.analysis.CancelStmt;
 import org.apache.doris.analysis.ColumnPosition;
 import org.apache.doris.analysis.CreateIndexClause;
+import org.apache.doris.analysis.CreateMaterializedViewStmt;
 import org.apache.doris.analysis.DropColumnClause;
 import org.apache.doris.analysis.DropIndexClause;
 import org.apache.doris.analysis.IndexDef;
@@ -672,52 +673,50 @@ public class SchemaChangeHandler extends AlterHandler {
                 }
                 List<Column> schema = entry.getValue();
                 for (Column column : schema) {
-                    if 
(column.getName().equalsIgnoreCase(modColumn.getName())) {
+                    String columnName = column.getName();
+                    if (column.isMaterializedViewColumn()) {
+                        columnName = MaterializedIndexMeta.normalizeName(
+                                
CreateMaterializedViewStmt.mvColumnBreaker(columnName));
+                    }
+                    if (columnName.equalsIgnoreCase(modColumn.getName())) {
                         otherIndexIds.add(entry.getKey());
                         break;
                     }
                 }
             }
-
-            if (KeysType.AGG_KEYS == olapTable.getKeysType() || 
KeysType.UNIQUE_KEYS == olapTable.getKeysType()) {
-                for (Long otherIndexId : otherIndexIds) {
-                    List<Column> otherIndexSchema = 
indexSchemaMap.get(otherIndexId);
+            for (Long otherIndexId : otherIndexIds) {
+                List<Column> otherIndexSchema = 
indexSchemaMap.get(otherIndexId);
+                for (int i = 0; i < otherIndexSchema.size(); i++) {
                     modColIndex = -1;
-                    for (int i = 0; i < otherIndexSchema.size(); i++) {
-                        if 
(otherIndexSchema.get(i).getName().equalsIgnoreCase(modColumn.getName())) {
-                            modColIndex = i;
-                            break;
-                        }
+                    Column otherCol = null;
+                    Column col = otherIndexSchema.get(i);
+                    String columnName = col.getName();
+                    if (col.isMaterializedViewColumn()) {
+                        columnName = MaterializedIndexMeta.normalizeName(
+                                
CreateMaterializedViewStmt.mvColumnBreaker(columnName));
                     }
-                    Preconditions.checkState(modColIndex != -1);
-                    // replace the old column
-                    otherIndexSchema.set(modColIndex, modColumn);
-                } //  end for other indices
-            } else {
-                // DUPLICATE data model has a little
-                for (Long otherIndexId : otherIndexIds) {
-                    List<Column> otherIndexSchema = 
indexSchemaMap.get(otherIndexId);
-                    modColIndex = -1;
-                    for (int i = 0; i < otherIndexSchema.size(); i++) {
-                        if 
(otherIndexSchema.get(i).getName().equalsIgnoreCase(modColumn.getName())) {
-                            modColIndex = i;
-                            break;
-                        }
+                    if (!columnName.equalsIgnoreCase(modColumn.getName())) {
+                        continue;
                     }
-
+                    modColIndex = i;
+                    otherCol = new Column(modColumn);
+                    otherCol.setName(col.getName());
+                    otherCol.setDefineExpr(col.getDefineExpr());
                     Preconditions.checkState(modColIndex != -1);
+                    Preconditions.checkState(otherCol != null);
                     // replace the old column
-                    Column oldCol = otherIndexSchema.get(modColIndex);
-                    Column otherCol = new Column(modColumn);
-                    otherCol.setIsKey(oldCol.isKey());
-                    if (null != oldCol.getAggregationType()) {
+                    if (KeysType.AGG_KEYS != olapTable.getKeysType()
+                            && KeysType.UNIQUE_KEYS != 
olapTable.getKeysType()) {
+                        Column oldCol = otherIndexSchema.get(modColIndex);
+                        otherCol.setIsKey(oldCol.isKey());
                         
otherCol.setAggregationType(oldCol.getAggregationType(), 
oldCol.isAggregationTypeImplicit());
-                    } else {
-                        otherCol.setAggregationType(null, 
oldCol.isAggregationTypeImplicit());
+                    }
+                    if (typeChanged && !lightSchemaChange) {
+                        otherCol.setName(SHADOW_NAME_PREFIX + 
otherCol.getName());
                     }
                     otherIndexSchema.set(modColIndex, otherCol);
                 }
-            }
+            } //  end for other indices
         } // end for handling other indices
 
         if (typeChanged && !lightSchemaChange) {
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeJobV2.java 
b/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeJobV2.java
index 277a3411541..8a75e32ddbc 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeJobV2.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeJobV2.java
@@ -430,30 +430,6 @@ public class SchemaChangeJobV2 extends AlterJobV2 {
             }
 
             Preconditions.checkState(tbl.getState() == 
OlapTableState.SCHEMA_CHANGE);
-
-            Map<String, Expr> defineExprs = Maps.newHashMap();
-            List<Column> fullSchema = tbl.getBaseSchema(true);
-            DescriptorTable descTable = new DescriptorTable();
-            TupleDescriptor destTupleDesc = descTable.createTupleDescriptor();
-            for (Column column : fullSchema) {
-                SlotDescriptor destSlotDesc = 
descTable.addSlotDescriptor(destTupleDesc);
-                destSlotDesc.setIsMaterialized(true);
-                destSlotDesc.setColumn(column);
-                destSlotDesc.setIsNullable(column.isAllowNull());
-
-                if 
(indexColumnMap.containsKey(SchemaChangeHandler.SHADOW_NAME_PREFIX + 
column.getName())) {
-                    Column newColumn = 
indexColumnMap.get(SchemaChangeHandler.SHADOW_NAME_PREFIX + column.getName());
-                    if (newColumn.getType() != column.getType()) {
-                        try {
-                            SlotRef slot = new SlotRef(destSlotDesc);
-                            slot.setCol(column.getName());
-                            defineExprs.put(column.getName(), 
slot.castTo(newColumn.getType()));
-                        } catch (AnalysisException e) {
-                            throw new AlterCancelException(e.getMessage());
-                        }
-                    }
-                }
-            }
             for (long partitionId : partitionIndexMap.rowKeySet()) {
                 Partition partition = tbl.getPartition(partitionId);
                 Preconditions.checkNotNull(partition, partitionId);
@@ -467,6 +443,30 @@ public class SchemaChangeJobV2 extends AlterJobV2 {
                     long shadowIdxId = entry.getKey();
                     MaterializedIndex shadowIdx = entry.getValue();
                     long originIdxId = indexIdMap.get(shadowIdxId);
+                    Map<String, Expr> defineExprs = Maps.newHashMap();
+                    List<Column> fullSchema = 
tbl.getSchemaByIndexId(originIdxId, true);
+                    DescriptorTable descTable = new DescriptorTable();
+                    TupleDescriptor destTupleDesc = 
descTable.createTupleDescriptor();
+                    for (Column column : fullSchema) {
+                        SlotDescriptor destSlotDesc = 
descTable.addSlotDescriptor(destTupleDesc);
+                        destSlotDesc.setIsMaterialized(true);
+                        destSlotDesc.setColumn(column);
+                        destSlotDesc.setIsNullable(column.isAllowNull());
+
+                        if 
(indexColumnMap.containsKey(SchemaChangeHandler.SHADOW_NAME_PREFIX + 
column.getName())) {
+                            Column newColumn = indexColumnMap.get(
+                                    SchemaChangeHandler.SHADOW_NAME_PREFIX + 
column.getName());
+                            if (newColumn.getType() != column.getType()) {
+                                try {
+                                    SlotRef slot = new SlotRef(destSlotDesc);
+                                    slot.setCol(column.getName());
+                                    defineExprs.put(column.getName(), 
slot.castTo(newColumn.getType()));
+                                } catch (AnalysisException e) {
+                                    throw new 
AlterCancelException(e.getMessage());
+                                }
+                            }
+                        }
+                    }
                     int shadowSchemaHash = 
indexSchemaVersionAndHashMap.get(shadowIdxId).schemaHash;
                     int originSchemaHash = 
tbl.getSchemaHashByIndexId(indexIdMap.get(shadowIdxId));
                     List<Column> originSchemaColumns = 
tbl.getSchemaByIndexId(originIdxId, true);
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateMaterializedViewStmt.java
 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateMaterializedViewStmt.java
index e3f856c31a4..5989141e3c6 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateMaterializedViewStmt.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateMaterializedViewStmt.java
@@ -671,7 +671,7 @@ public class CreateMaterializedViewStmt extends DdlStmt {
 
     public static String mvColumnBreaker(String name) {
         if (name.startsWith(MATERIALIZED_VIEW_AGGREGATE_NAME_PREFIX)) {
-            // mva_SUM__k2 -> k2
+            // mva_SUM__`k2` -> `k2`;
             return 
mvColumnBreaker(name.substring(name.indexOf(MATERIALIZED_VIEW_AGGREGATE_NAME_LINK)
                     + MATERIALIZED_VIEW_AGGREGATE_NAME_LINK.length()));
         } else if (name.startsWith(MATERIALIZED_VIEW_NAME_PREFIX)) {
diff --git 
a/regression-test/data/schema_change_p0/schema_change_modify_mv_column_type.out 
b/regression-test/data/schema_change_p0/schema_change_modify_mv_column_type.out
new file mode 100644
index 00000000000..4e6f3c7a5eb
--- /dev/null
+++ 
b/regression-test/data/schema_change_p0/schema_change_modify_mv_column_type.out
@@ -0,0 +1,103 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !sql --
+tbl_scalar_types_dup   DUP_KEYS        k1      BIGINT  BIGINT  Yes     true    
\N              true            
+               c_bool  BOOLEAN BOOLEAN Yes     false   \N      NONE    true    
        
+               c_tinyint       TINYINT TINYINT Yes     false   \N      NONE    
true            
+               c_smallint      SMALLINT        SMALLINT        Yes     false   
\N      NONE    true            
+               c_int   INT     INT     Yes     false   \N      NONE    true    
        
+               c_bigint        BIGINT  BIGINT  Yes     false   \N      NONE    
true            
+               c_largeint      LARGEINT        LARGEINT        Yes     false   
\N      NONE    true            
+               c_float FLOAT   FLOAT   Yes     false   \N      NONE    true    
        
+               c_double        DOUBLE  DOUBLE  Yes     false   \N      NONE    
true            
+               c_decimal       DECIMAL(20, 3)  DECIMALV3(20, 3)        Yes     
false   \N      NONE    true            
+               c_decimalv3     DECIMAL(20, 3)  DECIMALV3(20, 3)        Yes     
false   \N      NONE    true            
+               c_date  DATE    DATEV2  Yes     false   \N      NONE    true    
        
+               c_datetime      DATETIME        DATETIMEV2(0)   Yes     false   
\N      NONE    true            
+               c_datev2        DATE    DATEV2  Yes     false   \N      NONE    
true            
+               c_datetimev2    DATETIME        DATETIMEV2(0)   Yes     false   
\N      NONE    true            
+               c_char  CHAR(15)        CHAR(15)        Yes     false   \N      
NONE    true            
+               c_varchar       VARCHAR(100)    VARCHAR(100)    Yes     false   
\N      NONE    true            
+               c_string        TEXT    TEXT    Yes     false   \N      NONE    
true            
+                                                                               
        
+mv_tbl_scalar_types_dup_1      DUP_KEYS        mv_c_tinyint    TINYINT TINYINT 
Yes     true    \N              true    `c_tinyint`     
+               mv_c_bool       BOOLEAN BOOLEAN Yes     true    \N              
true    `c_bool`        
+               mv_k1   BIGINT  BIGINT  Yes     true    \N              true    
`k1`    
+               mv_c_smallint   SMALLINT        SMALLINT        Yes     false   
\N      NONE    true    `c_smallint`    
+               mv_c_int        INT     INT     Yes     false   \N      NONE    
true    `c_int` 
+               mv_c_bigint     BIGINT  BIGINT  Yes     false   \N      NONE    
true    `c_bigint`      
+               mv_c_largeint   LARGEINT        LARGEINT        Yes     false   
\N      NONE    true    `c_largeint`    
+               mv_c_float      FLOAT   FLOAT   Yes     false   \N      NONE    
true    `c_float`       
+               mv_c_double     DOUBLE  DOUBLE  Yes     false   \N      NONE    
true    `c_double`      
+               mv_c_decimal    DECIMAL(20, 3)  DECIMALV3(20, 3)        Yes     
false   \N      NONE    true    `c_decimal`     
+               mv_c_decimalv3  DECIMAL(20, 3)  DECIMALV3(20, 3)        Yes     
false   \N      NONE    true    `c_decimalv3`   
+               mv_c_date       DATE    DATEV2  Yes     false   \N      NONE    
true    `c_date`        
+               mv_c_datetime   DATETIME        DATETIMEV2(0)   Yes     false   
\N      NONE    true    `c_datetime`    
+               mv_c_datev2     DATE    DATEV2  Yes     false   \N      NONE    
true    `c_datev2`      
+               mv_c_datetimev2 DATETIME        DATETIMEV2(0)   Yes     false   
\N      NONE    true    `c_datetimev2`  
+               mv_c_char       CHARACTER       CHARACTER       Yes     false   
\N      NONE    true    `c_char`        
+               mv_c_varchar    VARCHAR(65533)  VARCHAR(65533)  Yes     false   
\N      NONE    true    `c_varchar`     
+               mv_c_string     TEXT    TEXT    Yes     false   \N      NONE    
true    `c_string`      
+
+-- !sql --
+-2147475406    true    45      23794   -11023  915989078       2115356192      
15927.068       1.392557423391501E9     45951348783208518.810   
8340516346665031.310    2022-01-26      2022-04-13T11:13:48     2022-01-31      
2022-02-16T06:07:21     130.50.6.0      denisematth...@yozio.mil        
Londonderry Alley 61
+-2147424303    false   -28     -5177   -1409   149417728       553396597       
-10123.558      -1.268722910924068E9    67354830622005524.848   
52407243294991364.348   2022-06-29      2022-05-06T09:30:02     2023-01-09      
2022-03-12T14:26        109.50.92.119   craighug...@talane.biz  Heath Drive 38
+-2147413967    true    -75     30533   -5435   -727385447      32929830        
9577.564        1.334766997510087E9     39973144022098028.800   
5886463393340733.108    2022-06-23      2022-05-10T19:13:50     2022-01-17      
2022-11-26T22:49:36     157.38.90.25    joshuale...@jayo.mil    Loeprich 
Crossing 43
+-2147380173    true    -79     -5785   9752    1851350218      1121852298      
25652.402       -1.618061059513558E9    95821873014545736.897   
38923569966532828.626   2022-10-30      2022-05-02T17:06:33     2022-08-11      
2022-02-08T10:19:47     217.198.98.239  joseb...@voonder.info   Lawn Lane 78
+-2147374459    false   -118    -30267  -14606  262497842       -1811881704     
8211.805        2.37851933046663E8      37354136531251060.755   
63024710145324035.720   2022-10-11      2022-01-17T10:20:18     2022-04-12      
2022-10-24T18:14:38     16.243.195.81   brendab...@talane.net   Annamark Pass 72
+-2147369329    false   -121    -22859  4733    -378861997      385323541       
-22969.846      1.483825622420542E9     50940877800950041.950   
87108729227937387.294   2022-06-05      2022-08-18T05:39:56     2022-08-21      
2022-12-12T08:43:59     16.27.107.167   phyllissm...@zoombox.org        Village 
Green Terrace 55
+-2147367329    true    84      21471   -29331  1823545950      1200800855      
-13832.219      8.01505090724918E8      45495296019797580.477   
45196001436348967.557   2022-02-17      2022-05-23T01:44:31     2022-08-01      
2022-08-16T10:32:36     84.110.209.128  vl...@dablist.edu       Packers Street 
34
+-2147339287    true    62      28989   -32018  650184880       -365849435      
-21644.414      -7.8648426469503E7      92593387160450273.870   
39588697152489527.185   2022-07-23      2023-01-03T11:54:35     2022-08-02      
2022-05-19T18:35:36     30.194.6.115    ven...@thoughtstorm.mil Basil Street 79
+-2147336695    false   42      -7202   27919   1898713395      1177326785      
-302.0104       -1.268944460183375E9    61604656210729534.717   
6683002058708470.832    2022-08-20      2022-08-14T01:41:12     2022-11-02      
2022-05-15T04:22:07     36.86.77.214    delectus_maiores_fu...@rhyzio.org       
Briar Crest Crossing 37
+-2147330925    false   -122    -21211  -2331   1906695924      -1342280417     
5545.3013       -1.286038914681617E9    31911132334645267.930   
84364209624711210.131   2022-02-16      2022-03-11T12:05:33     2022-11-24      
2022-12-17T19:56:16     6.87.14.74      rcampb...@riffpath.com  Forest Run 
Terrace 13
+
+-- !sql --
+-2145739104    true    10      -22603  6132    -984517723      138439036       
8683.904        1.681202635040786E9     49683339998558535.395   
38251259739648714.297   2022-04-26      2022-09-12T00:32:18     2022-11-20      
2023-01-09T16:19:06     180.215.212.86  kathyrobe...@talane.info        Darwin 
Center 26
+-2140012242    false   10      30893   -16192  -175522451      -1382546546     
21324.643       2.017216342012696E9     41477187479096470.647   
25445001389089818.791   2022-11-06      2022-09-02T12:04:05     2022-05-29      
2022-02-04T22:21:46     24.25.69.81     nam_qu...@photospace.mil        Jay Way 
9
+-2130269306    false   10      30342   -18732  1461226453      -1257020753     
-10751.815      3.44246067782915E8      2456538047280540.838    
37394928326629689.946   2022-11-28      2022-05-04T20:40:19     2022-08-25      
2022-03-18T10:17:35     179.198.200.96  eful...@skynoodle.com   Tennyson Street 
83
+-2122709724    true    10      -8985   -30620  -1375603501     631094037       
14711.055       -1.210030062083139E9    96220820029888063.156   
42161382030214480.728   2022-05-28      2023-01-03T20:44:27     2022-06-11      
2022-07-26T22:49:22     13.249.135.222  udi...@shufflebeat.name Riverside 
Parkway 72
+-2117749737    false   10      26335   30644   1841596444      283308539       
18848.148       3.5339747538014E8       11924963560520504.166   
28287350935413049.601   2022-08-01      2022-04-21T02:28:54     2022-02-27      
2022-09-02T17:11:17     183.108.102.1   phan...@cogibox.com     Maple Wood 
Street 40
+-2113239713    false   10      27624   31311   711781944       -1838033894     
-12299.482      -1.88263132184351E9     9480201396831049.605    
52114965946122870.302   2022-06-11      2022-08-31T08:54:30     2022-03-26      
2023-01-08T23:28:27     200.161.156.176 e...@buzzster.net       Westport Drive 
82
+-2107773486    false   10      27096   10368   1579374450      1370327646      
-15339.031      2.110010890135424E9     54514853031265543.378   
38546969634312019.180   2022-12-31      2022-10-07T10:18:27     2022-10-01      
2022-07-09T11:41:11     121.120.227.53  juliad...@plambee.com   Sugar Crossing 
43
+-2107242025    true    10      25215   26566   1292568651      -2126795906     
11912.074       -2.140044503516609E9    98695561934257164.368   
18845397264645075.775   2022-05-21      2022-09-24T23:00:21     2022-02-12      
2022-11-24T19:17:03     141.226.90.50   annagonza...@eimbee.mil Cody Street 78
+-2106969609    true    10      29572   16738   1736115820      -957295886      
-13319.206      -1.333603562816737E9    91224478600376111.942   
69457425159617037.453   2022-09-06      2022-05-08T19:52:36     2022-04-05      
2022-08-17T19:23:31     222.79.139.99   walter...@voomm.net     Oxford Alley 77
+-2102307005    true    10      -23674  24613   -1810828490     -47095409       
-14686.167      2.072108685694799E9     39847820962230526.125   
584354832299375.156     2022-03-27      2022-02-11T13:46:06     2022-12-25      
2022-11-28T09:37:49     213.146.33.250  juliasimm...@zazio.info Eagle Crest 
Terrace 84
+
+-- !sql --
+tbl_scalar_types_dup   DUP_KEYS        k1      BIGINT  BIGINT  Yes     true    
\N              true            
+               c_bool  BOOLEAN BOOLEAN Yes     false   \N      NONE    true    
        
+               c_tinyint       TINYINT TINYINT Yes     false   \N      NONE    
true            
+               c_smallint      SMALLINT        SMALLINT        Yes     false   
\N      NONE    true            
+               c_int   BIGINT  BIGINT  Yes     false   \N      NONE    true    
        
+               c_bigint        BIGINT  BIGINT  Yes     false   \N      NONE    
true            
+               c_largeint      LARGEINT        LARGEINT        Yes     false   
\N      NONE    true            
+               c_float FLOAT   FLOAT   Yes     false   \N      NONE    true    
        
+               c_double        DOUBLE  DOUBLE  Yes     false   \N      NONE    
true            
+               c_decimal       DECIMAL(20, 3)  DECIMALV3(20, 3)        Yes     
false   \N      NONE    true            
+               c_decimalv3     DECIMAL(20, 3)  DECIMALV3(20, 3)        Yes     
false   \N      NONE    true            
+               c_date  DATE    DATEV2  Yes     false   \N      NONE    true    
        
+               c_datetime      DATETIME        DATETIMEV2(0)   Yes     false   
\N      NONE    true            
+               c_datev2        DATE    DATEV2  Yes     false   \N      NONE    
true            
+               c_datetimev2    DATETIME        DATETIMEV2(0)   Yes     false   
\N      NONE    true            
+               c_char  CHAR(15)        CHAR(15)        Yes     false   \N      
NONE    true            
+               c_varchar       VARCHAR(100)    VARCHAR(100)    Yes     false   
\N      NONE    true            
+               c_string        TEXT    TEXT    Yes     false   \N      NONE    
true            
+                                                                               
        
+mv_tbl_scalar_types_dup_1      DUP_KEYS        mv_c_tinyint    TINYINT TINYINT 
Yes     true    \N              true    `c_tinyint`     
+               mv_c_bool       BOOLEAN BOOLEAN Yes     true    \N              
true    `c_bool`        
+               mv_k1   BIGINT  BIGINT  Yes     true    \N              true    
`k1`    
+               mv_c_smallint   SMALLINT        SMALLINT        Yes     false   
\N      NONE    true    `c_smallint`    
+               mv_c_int        BIGINT  BIGINT  Yes     false   \N      NONE    
true    `c_int` 
+               mv_c_bigint     BIGINT  BIGINT  Yes     false   \N      NONE    
true    `c_bigint`      
+               mv_c_largeint   LARGEINT        LARGEINT        Yes     false   
\N      NONE    true    `c_largeint`    
+               mv_c_float      FLOAT   FLOAT   Yes     false   \N      NONE    
true    `c_float`       
+               mv_c_double     DOUBLE  DOUBLE  Yes     false   \N      NONE    
true    `c_double`      
+               mv_c_decimal    DECIMAL(20, 3)  DECIMALV3(20, 3)        Yes     
false   \N      NONE    true    `c_decimal`     
+               mv_c_decimalv3  DECIMAL(20, 3)  DECIMALV3(20, 3)        Yes     
false   \N      NONE    true    `c_decimalv3`   
+               mv_c_date       DATE    DATEV2  Yes     false   \N      NONE    
true    `c_date`        
+               mv_c_datetime   DATETIME        DATETIMEV2(0)   Yes     false   
\N      NONE    true    `c_datetime`    
+               mv_c_datev2     DATE    DATEV2  Yes     false   \N      NONE    
true    `c_datev2`      
+               mv_c_datetimev2 DATETIME        DATETIMEV2(0)   Yes     false   
\N      NONE    true    `c_datetimev2`  
+               mv_c_char       CHARACTER       CHARACTER       Yes     false   
\N      NONE    true    `c_char`        
+               mv_c_varchar    VARCHAR(65533)  VARCHAR(65533)  Yes     false   
\N      NONE    true    `c_varchar`     
+               mv_c_string     TEXT    TEXT    Yes     false   \N      NONE    
true    `c_string`      
+
diff --git 
a/regression-test/data/schema_change_p0/schema_change_modify_mv_column_type2.out
 
b/regression-test/data/schema_change_p0/schema_change_modify_mv_column_type2.out
new file mode 100644
index 00000000000..e8f586247cb
--- /dev/null
+++ 
b/regression-test/data/schema_change_p0/schema_change_modify_mv_column_type2.out
@@ -0,0 +1,75 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !sql --
+tbl_scalar_types_dup   DUP_KEYS        k1      BIGINT  BIGINT  Yes     true    
\N              true            
+               c_bool  BOOLEAN BOOLEAN Yes     false   \N      NONE    true    
        
+               c_tinyint       TINYINT TINYINT Yes     false   \N      NONE    
true            
+               c_smallint      SMALLINT        SMALLINT        Yes     false   
\N      NONE    true            
+               c_int   INT     INT     Yes     false   \N      NONE    true    
        
+               c_bigint        BIGINT  BIGINT  Yes     false   \N      NONE    
true            
+               c_largeint      LARGEINT        LARGEINT        Yes     false   
\N      NONE    true            
+               c_float FLOAT   FLOAT   Yes     false   \N      NONE    true    
        
+               c_double        DOUBLE  DOUBLE  Yes     false   \N      NONE    
true            
+               c_decimal       DECIMAL(20, 3)  DECIMALV3(20, 3)        Yes     
false   \N      NONE    true            
+               c_decimalv3     DECIMAL(20, 3)  DECIMALV3(20, 3)        Yes     
false   \N      NONE    true            
+               c_date  DATE    DATEV2  Yes     false   \N      NONE    true    
        
+               c_datetime      DATETIME        DATETIMEV2(0)   Yes     false   
\N      NONE    true            
+               c_datev2        DATE    DATEV2  Yes     false   \N      NONE    
true            
+               c_datetimev2    DATETIME        DATETIMEV2(0)   Yes     false   
\N      NONE    true            
+               c_char  CHAR(15)        CHAR(15)        Yes     false   \N      
NONE    true            
+               c_varchar       VARCHAR(100)    VARCHAR(100)    Yes     false   
\N      NONE    true            
+               c_string        TEXT    TEXT    Yes     false   \N      NONE    
true            
+                                                                               
        
+mv_tbl_scalar_types_dup_2      AGG_KEYS        mv_k1   BIGINT  BIGINT  Yes     
true    \N              true    `k1`    
+               mva_SUM__CAST(`c_int` AS BIGINT)        BIGINT  BIGINT  Yes     
false   \N      SUM     true    CAST(`c_int` AS BIGINT) 
+               mva_MAX__`c_int`        INT     INT     Yes     false   \N      
MAX     true    `c_int` 
+               mva_MIN__`c_int`        INT     INT     Yes     false   \N      
MIN     true    `c_int` 
+
+-- !sql --
+-2147475406    true    45      23794   -11023  915989078       2115356192      
15927.068       1.392557423391501E9     45951348783208518.810   
8340516346665031.310    2022-01-26      2022-04-13T11:13:48     2022-01-31      
2022-02-16T06:07:21     130.50.6.0      denisematth...@yozio.mil        
Londonderry Alley 61
+-2147424303    false   -28     -5177   -1409   149417728       553396597       
-10123.558      -1.268722910924068E9    67354830622005524.848   
52407243294991364.348   2022-06-29      2022-05-06T09:30:02     2023-01-09      
2022-03-12T14:26        109.50.92.119   craighug...@talane.biz  Heath Drive 38
+-2147413967    true    -75     30533   -5435   -727385447      32929830        
9577.564        1.334766997510087E9     39973144022098028.800   
5886463393340733.108    2022-06-23      2022-05-10T19:13:50     2022-01-17      
2022-11-26T22:49:36     157.38.90.25    joshuale...@jayo.mil    Loeprich 
Crossing 43
+-2147380173    true    -79     -5785   9752    1851350218      1121852298      
25652.402       -1.618061059513558E9    95821873014545736.897   
38923569966532828.626   2022-10-30      2022-05-02T17:06:33     2022-08-11      
2022-02-08T10:19:47     217.198.98.239  joseb...@voonder.info   Lawn Lane 78
+-2147374459    false   -118    -30267  -14606  262497842       -1811881704     
8211.805        2.37851933046663E8      37354136531251060.755   
63024710145324035.720   2022-10-11      2022-01-17T10:20:18     2022-04-12      
2022-10-24T18:14:38     16.243.195.81   brendab...@talane.net   Annamark Pass 72
+-2147369329    false   -121    -22859  4733    -378861997      385323541       
-22969.846      1.483825622420542E9     50940877800950041.950   
87108729227937387.294   2022-06-05      2022-08-18T05:39:56     2022-08-21      
2022-12-12T08:43:59     16.27.107.167   phyllissm...@zoombox.org        Village 
Green Terrace 55
+-2147367329    true    84      21471   -29331  1823545950      1200800855      
-13832.219      8.01505090724918E8      45495296019797580.477   
45196001436348967.557   2022-02-17      2022-05-23T01:44:31     2022-08-01      
2022-08-16T10:32:36     84.110.209.128  vl...@dablist.edu       Packers Street 
34
+-2147339287    true    62      28989   -32018  650184880       -365849435      
-21644.414      -7.8648426469503E7      92593387160450273.870   
39588697152489527.185   2022-07-23      2023-01-03T11:54:35     2022-08-02      
2022-05-19T18:35:36     30.194.6.115    ven...@thoughtstorm.mil Basil Street 79
+-2147336695    false   42      -7202   27919   1898713395      1177326785      
-302.0104       -1.268944460183375E9    61604656210729534.717   
6683002058708470.832    2022-08-20      2022-08-14T01:41:12     2022-11-02      
2022-05-15T04:22:07     36.86.77.214    delectus_maiores_fu...@rhyzio.org       
Briar Crest Crossing 37
+-2147330925    false   -122    -21211  -2331   1906695924      -1342280417     
5545.3013       -1.286038914681617E9    31911132334645267.930   
84364209624711210.131   2022-02-16      2022-03-11T12:05:33     2022-11-24      
2022-12-17T19:56:16     6.87.14.74      rcampb...@riffpath.com  Forest Run 
Terrace 13
+
+-- !sql --
+-2145739104    true    10      -22603  6132    -984517723      138439036       
8683.904        1.681202635040786E9     49683339998558535.395   
38251259739648714.297   2022-04-26      2022-09-12T00:32:18     2022-11-20      
2023-01-09T16:19:06     180.215.212.86  kathyrobe...@talane.info        Darwin 
Center 26
+-2140012242    false   10      30893   -16192  -175522451      -1382546546     
21324.643       2.017216342012696E9     41477187479096470.647   
25445001389089818.791   2022-11-06      2022-09-02T12:04:05     2022-05-29      
2022-02-04T22:21:46     24.25.69.81     nam_qu...@photospace.mil        Jay Way 
9
+-2130269306    false   10      30342   -18732  1461226453      -1257020753     
-10751.815      3.44246067782915E8      2456538047280540.838    
37394928326629689.946   2022-11-28      2022-05-04T20:40:19     2022-08-25      
2022-03-18T10:17:35     179.198.200.96  eful...@skynoodle.com   Tennyson Street 
83
+-2122709724    true    10      -8985   -30620  -1375603501     631094037       
14711.055       -1.210030062083139E9    96220820029888063.156   
42161382030214480.728   2022-05-28      2023-01-03T20:44:27     2022-06-11      
2022-07-26T22:49:22     13.249.135.222  udi...@shufflebeat.name Riverside 
Parkway 72
+-2117749737    false   10      26335   30644   1841596444      283308539       
18848.148       3.5339747538014E8       11924963560520504.166   
28287350935413049.601   2022-08-01      2022-04-21T02:28:54     2022-02-27      
2022-09-02T17:11:17     183.108.102.1   phan...@cogibox.com     Maple Wood 
Street 40
+-2113239713    false   10      27624   31311   711781944       -1838033894     
-12299.482      -1.88263132184351E9     9480201396831049.605    
52114965946122870.302   2022-06-11      2022-08-31T08:54:30     2022-03-26      
2023-01-08T23:28:27     200.161.156.176 e...@buzzster.net       Westport Drive 
82
+-2107773486    false   10      27096   10368   1579374450      1370327646      
-15339.031      2.110010890135424E9     54514853031265543.378   
38546969634312019.180   2022-12-31      2022-10-07T10:18:27     2022-10-01      
2022-07-09T11:41:11     121.120.227.53  juliad...@plambee.com   Sugar Crossing 
43
+-2107242025    true    10      25215   26566   1292568651      -2126795906     
11912.074       -2.140044503516609E9    98695561934257164.368   
18845397264645075.775   2022-05-21      2022-09-24T23:00:21     2022-02-12      
2022-11-24T19:17:03     141.226.90.50   annagonza...@eimbee.mil Cody Street 78
+-2106969609    true    10      29572   16738   1736115820      -957295886      
-13319.206      -1.333603562816737E9    91224478600376111.942   
69457425159617037.453   2022-09-06      2022-05-08T19:52:36     2022-04-05      
2022-08-17T19:23:31     222.79.139.99   walter...@voomm.net     Oxford Alley 77
+-2102307005    true    10      -23674  24613   -1810828490     -47095409       
-14686.167      2.072108685694799E9     39847820962230526.125   
584354832299375.156     2022-03-27      2022-02-11T13:46:06     2022-12-25      
2022-11-28T09:37:49     213.146.33.250  juliasimm...@zazio.info Eagle Crest 
Terrace 84
+
+-- !sql --
+tbl_scalar_types_dup   DUP_KEYS        k1      BIGINT  BIGINT  Yes     true    
\N              true            
+               c_bool  BOOLEAN BOOLEAN Yes     false   \N      NONE    true    
        
+               c_tinyint       TINYINT TINYINT Yes     false   \N      NONE    
true            
+               c_smallint      SMALLINT        SMALLINT        Yes     false   
\N      NONE    true            
+               c_int   BIGINT  BIGINT  Yes     false   \N      NONE    true    
        
+               c_bigint        BIGINT  BIGINT  Yes     false   \N      NONE    
true            
+               c_largeint      LARGEINT        LARGEINT        Yes     false   
\N      NONE    true            
+               c_float FLOAT   FLOAT   Yes     false   \N      NONE    true    
        
+               c_double        DOUBLE  DOUBLE  Yes     false   \N      NONE    
true            
+               c_decimal       DECIMAL(20, 3)  DECIMALV3(20, 3)        Yes     
false   \N      NONE    true            
+               c_decimalv3     DECIMAL(20, 3)  DECIMALV3(20, 3)        Yes     
false   \N      NONE    true            
+               c_date  DATE    DATEV2  Yes     false   \N      NONE    true    
        
+               c_datetime      DATETIME        DATETIMEV2(0)   Yes     false   
\N      NONE    true            
+               c_datev2        DATE    DATEV2  Yes     false   \N      NONE    
true            
+               c_datetimev2    DATETIME        DATETIMEV2(0)   Yes     false   
\N      NONE    true            
+               c_char  CHAR(15)        CHAR(15)        Yes     false   \N      
NONE    true            
+               c_varchar       VARCHAR(100)    VARCHAR(100)    Yes     false   
\N      NONE    true            
+               c_string        TEXT    TEXT    Yes     false   \N      NONE    
true            
+                                                                               
        
+mv_tbl_scalar_types_dup_2      AGG_KEYS        mv_k1   BIGINT  BIGINT  Yes     
true    \N              true    `k1`    
+               mva_SUM__CAST(`c_int` AS BIGINT)        BIGINT  BIGINT  Yes     
false   \N      SUM     true    CAST(`c_int` AS BIGINT) 
+               mva_MAX__`c_int`        BIGINT  BIGINT  Yes     false   \N      
MAX     true    `c_int` 
+               mva_MIN__`c_int`        BIGINT  BIGINT  Yes     false   \N      
MIN     true    `c_int` 
+
diff --git 
a/regression-test/data/schema_change_p0/schema_change_modify_mv_column_type_agg.out
 
b/regression-test/data/schema_change_p0/schema_change_modify_mv_column_type_agg.out
new file mode 100644
index 00000000000..2de215cbd50
--- /dev/null
+++ 
b/regression-test/data/schema_change_p0/schema_change_modify_mv_column_type_agg.out
@@ -0,0 +1,55 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !sql --
+tbl_scalar_types_agg   AGG_KEYS        k1      BIGINT  BIGINT  Yes     true    
\N              true            
+               k2      BIGINT  BIGINT  Yes     true    \N              true    
        
+               c_bool  BOOLEAN BOOLEAN Yes     false   \N      REPLACE true    
        
+               c_tinyint       TINYINT TINYINT Yes     false   \N      MIN     
true            
+               c_smallint      SMALLINT        SMALLINT        Yes     false   
\N      MAX     true            
+               c_int   INT     INT     Yes     false   \N      MAX     true    
        
+               c_bigint        BIGINT  BIGINT  Yes     false   \N      SUM     
true            
+               c_largeint      LARGEINT        LARGEINT        Yes     false   
\N      MIN     true            
+               c_float FLOAT   FLOAT   Yes     false   \N      MIN     true    
        
+               c_double        DOUBLE  DOUBLE  Yes     false   \N      MAX     
true            
+               c_decimal       DECIMAL(20, 3)  DECIMALV3(20, 3)        Yes     
false   \N      SUM     true            
+               c_decimalv3     DECIMAL(20, 3)  DECIMALV3(20, 3)        Yes     
false   \N      SUM     true            
+               c_date  DATE    DATEV2  Yes     false   \N      REPLACE true    
        
+               c_datetime      DATETIME        DATETIMEV2(0)   Yes     false   
\N      REPLACE true            
+               c_datev2        DATE    DATEV2  Yes     false   \N      REPLACE 
true            
+               c_datetimev2    DATETIME        DATETIMEV2(0)   Yes     false   
\N      REPLACE true            
+               c_char  CHAR(15)        CHAR(15)        Yes     false   \N      
REPLACE true            
+               c_varchar       VARCHAR(100)    VARCHAR(100)    Yes     false   
\N      REPLACE true            
+               c_string        TEXT    TEXT    Yes     false   \N      REPLACE 
true            
+                                                                               
        
+mv_tbl_scalar_types_agg_1      AGG_KEYS        mv_k2   BIGINT  BIGINT  Yes     
true    \N              true    `k2`    
+               mv_k1   BIGINT  BIGINT  Yes     true    \N              true    
`k1`    
+               mva_MAX__`c_int`        INT     INT     Yes     false   \N      
MAX     true    `c_int` 
+
+-- !sql --
+
+-- !sql --
+
+-- !sql --
+tbl_scalar_types_agg   AGG_KEYS        k1      BIGINT  BIGINT  Yes     true    
\N              true            
+               k2      BIGINT  BIGINT  Yes     true    \N              true    
        
+               c_bool  BOOLEAN BOOLEAN Yes     false   \N      REPLACE true    
        
+               c_tinyint       TINYINT TINYINT Yes     false   \N      MIN     
true            
+               c_smallint      SMALLINT        SMALLINT        Yes     false   
\N      MAX     true            
+               c_int   BIGINT  BIGINT  Yes     false   \N      MAX     true    
        
+               c_bigint        BIGINT  BIGINT  Yes     false   \N      SUM     
true            
+               c_largeint      LARGEINT        LARGEINT        Yes     false   
\N      MIN     true            
+               c_float FLOAT   FLOAT   Yes     false   \N      MIN     true    
        
+               c_double        DOUBLE  DOUBLE  Yes     false   \N      MAX     
true            
+               c_decimal       DECIMAL(20, 3)  DECIMALV3(20, 3)        Yes     
false   \N      SUM     true            
+               c_decimalv3     DECIMAL(20, 3)  DECIMALV3(20, 3)        Yes     
false   \N      SUM     true            
+               c_date  DATE    DATEV2  Yes     false   \N      REPLACE true    
        
+               c_datetime      DATETIME        DATETIMEV2(0)   Yes     false   
\N      REPLACE true            
+               c_datev2        DATE    DATEV2  Yes     false   \N      REPLACE 
true            
+               c_datetimev2    DATETIME        DATETIMEV2(0)   Yes     false   
\N      REPLACE true            
+               c_char  CHAR(15)        CHAR(15)        Yes     false   \N      
REPLACE true            
+               c_varchar       VARCHAR(100)    VARCHAR(100)    Yes     false   
\N      REPLACE true            
+               c_string        TEXT    TEXT    Yes     false   \N      REPLACE 
true            
+                                                                               
        
+mv_tbl_scalar_types_agg_1      AGG_KEYS        mv_k2   BIGINT  BIGINT  Yes     
true    \N              true    `k2`    
+               mv_k1   BIGINT  BIGINT  Yes     true    \N              true    
`k1`    
+               mva_MAX__`c_int`        BIGINT  BIGINT  Yes     false   \N      
MAX     true    `c_int` 
+
diff --git 
a/regression-test/suites/schema_change_p0/schema_change_modify_mv_column_type.groovy
 
b/regression-test/suites/schema_change_p0/schema_change_modify_mv_column_type.groovy
new file mode 100644
index 00000000000..856b207f3b4
--- /dev/null
+++ 
b/regression-test/suites/schema_change_p0/schema_change_modify_mv_column_type.groovy
@@ -0,0 +1,98 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+import org.codehaus.groovy.runtime.IOGroovyMethods
+
+suite("schema_change_modify_mv_column_type") {
+    //test legacy planner
+
+    def dataFile = 
"""${getS3Url()}/regression/datatypes/test_scalar_types_10w.csv"""
+
+    // define dup key table1
+    def testTable = "tbl_scalar_types_dup"
+    sql "DROP TABLE IF EXISTS ${testTable} FORCE"
+    sql """
+        CREATE TABLE IF NOT EXISTS ${testTable} (
+            `k1` bigint(11) NULL,
+            `c_bool` boolean NULL,
+            `c_tinyint` tinyint(4) NULL,
+            `c_smallint` smallint(6) NULL,
+            `c_int` int(11) NULL,
+            `c_bigint` bigint(20) NULL,
+            `c_largeint` largeint(40) NULL,
+            `c_float` float NULL,
+            `c_double` double NULL,
+            `c_decimal` decimal(20, 3) NULL,
+            `c_decimalv3` decimalv3(20, 3) NULL,
+            `c_date` date NULL,
+            `c_datetime` datetime NULL,
+            `c_datev2` datev2 NULL,
+            `c_datetimev2` datetimev2(0) NULL,
+            `c_char` char(15) NULL,
+            `c_varchar` varchar(100) NULL,
+            `c_string` text NULL
+        ) ENGINE=OLAP
+        DUPLICATE KEY(`k1`)
+        COMMENT 'OLAP'
+        DISTRIBUTED BY HASH(`k1`) BUCKETS 1
+        PROPERTIES("replication_num" = "1");
+        """
+
+    // load data
+    streamLoad {
+        table testTable
+        file dataFile
+        time 60000
+
+        check { result, exception, startTime, endTime ->
+            if (exception != null) {
+                throw exception
+            }
+            log.info("Stream load result: ${result}".toString())
+            def json = parseJson(result)
+            assertEquals(100000, json.NumberTotalRows)
+            assertEquals(100000, json.NumberLoadedRows)
+        }
+    }
+    createMV ("""CREATE MATERIALIZED VIEW mv_${testTable}_1 AS SELECT 
c_tinyint, c_bool, k1, c_smallint, c_int, c_bigint, c_largeint, c_float, 
c_double,  c_decimal, c_decimalv3, c_date, c_datetime, c_datev2, c_datetimev2, 
c_char, c_varchar, c_string FROM ${testTable} ORDER BY c_tinyint, c_bool, k1""")
+    qt_sql """ desc ${testTable} all """
+    sql "set topn_opt_limit_threshold = 100"
+    qt_sql "SELECT * from ${testTable} order by 1, 2, 3 limit 10"
+    qt_sql "SELECT * from ${testTable} where c_tinyint = 10 order by 1, 2, 3 
limit 10 "
+
+    sql """
+          ALTER table ${testTable} MODIFY COLUMN c_int BIGINT;
+          """
+    def getJobState = { tableName ->
+          def jobStateResult = sql """  SHOW ALTER TABLE COLUMN WHERE 
IndexName='${tableName}' ORDER BY createtime DESC LIMIT 1 """
+          return jobStateResult[0][9]
+     }
+    int max_try_time = 100
+    while (max_try_time--){
+        String result = getJobState(testTable)
+        if (result == "FINISHED") {
+            break
+        } else {
+            sleep(2000)
+            if (max_try_time < 1){
+                assertEquals(1,2)
+            }
+        }
+    }
+    qt_sql """ desc ${testTable} all """
+    sql "INSERT INTO ${testTable} SELECT * from ${testTable}"
+}
diff --git 
a/regression-test/suites/schema_change_p0/schema_change_modify_mv_column_type2.groovy
 
b/regression-test/suites/schema_change_p0/schema_change_modify_mv_column_type2.groovy
new file mode 100644
index 00000000000..f34fb6b3f97
--- /dev/null
+++ 
b/regression-test/suites/schema_change_p0/schema_change_modify_mv_column_type2.groovy
@@ -0,0 +1,98 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+import org.codehaus.groovy.runtime.IOGroovyMethods
+
+suite("schema_change_modify_mv_column_type2") {
+    //test legacy planner
+
+    def dataFile = 
"""${getS3Url()}/regression/datatypes/test_scalar_types_10w.csv"""
+
+    // define dup key table1
+    def testTable = "tbl_scalar_types_dup"
+    sql "DROP TABLE IF EXISTS ${testTable} FORCE"
+    sql """
+        CREATE TABLE IF NOT EXISTS ${testTable} (
+            `k1` bigint(11) NULL,
+            `c_bool` boolean NULL,
+            `c_tinyint` tinyint(4) NULL,
+            `c_smallint` smallint(6) NULL,
+            `c_int` int(11) NULL,
+            `c_bigint` bigint(20) NULL,
+            `c_largeint` largeint(40) NULL,
+            `c_float` float NULL,
+            `c_double` double NULL,
+            `c_decimal` decimal(20, 3) NULL,
+            `c_decimalv3` decimalv3(20, 3) NULL,
+            `c_date` date NULL,
+            `c_datetime` datetime NULL,
+            `c_datev2` datev2 NULL,
+            `c_datetimev2` datetimev2(0) NULL,
+            `c_char` char(15) NULL,
+            `c_varchar` varchar(100) NULL,
+            `c_string` text NULL
+        ) ENGINE=OLAP
+        DUPLICATE KEY(`k1`)
+        COMMENT 'OLAP'
+        DISTRIBUTED BY HASH(`k1`) BUCKETS 1
+        PROPERTIES("replication_num" = "1");
+        """
+
+    // load data
+    streamLoad {
+        table testTable
+        file dataFile
+        time 60000
+
+        check { result, exception, startTime, endTime ->
+            if (exception != null) {
+                throw exception
+            }
+            log.info("Stream load result: ${result}".toString())
+            def json = parseJson(result)
+            assertEquals(100000, json.NumberTotalRows)
+            assertEquals(100000, json.NumberLoadedRows)
+        }
+    }
+    createMV ("""CREATE MATERIALIZED VIEW mv_${testTable}_2 AS SELECT k1, 
sum(c_int), max(c_int), min(c_int) FROM ${testTable} GROUP BY k1""")
+    qt_sql """ desc ${testTable} all """
+    sql "set topn_opt_limit_threshold = 100"
+    qt_sql "SELECT * from ${testTable} order by 1, 2, 3 limit 10"
+    qt_sql "SELECT * from ${testTable} where c_tinyint = 10 order by 1, 2, 3 
limit 10 "
+
+    sql """
+          ALTER table ${testTable} MODIFY COLUMN c_int BIGINT;
+          """
+    def getJobState = { tableName ->
+          def jobStateResult = sql """  SHOW ALTER TABLE COLUMN WHERE 
IndexName='${tableName}' ORDER BY createtime DESC LIMIT 1 """
+          return jobStateResult[0][9]
+     }
+    int max_try_time = 100
+    while (max_try_time--){
+        String result = getJobState(testTable)
+        if (result == "FINISHED") {
+            break
+        } else {
+            sleep(2000)
+            if (max_try_time < 1){
+                assertEquals(1,2)
+            }
+        }
+    }
+    qt_sql """ desc ${testTable} all """
+    sql "INSERT INTO ${testTable} SELECT * from ${testTable}"
+}
diff --git 
a/regression-test/suites/schema_change_p0/schema_change_modify_mv_column_type_agg.groovy
 
b/regression-test/suites/schema_change_p0/schema_change_modify_mv_column_type_agg.groovy
new file mode 100644
index 00000000000..c1613c69625
--- /dev/null
+++ 
b/regression-test/suites/schema_change_p0/schema_change_modify_mv_column_type_agg.groovy
@@ -0,0 +1,97 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+import org.codehaus.groovy.runtime.IOGroovyMethods
+
+suite("schema_change_modify_mv_column_type_agg") {
+    //test legacy planner
+
+    def dataFile = 
"""${getS3Url()}/regression/datatypes/test_scalar_types_10w.csv"""
+
+    // define dup key table1
+    def testTable = "tbl_scalar_types_agg"
+    sql "DROP TABLE IF EXISTS ${testTable} FORCE"
+    sql """
+        CREATE TABLE IF NOT EXISTS ${testTable} (
+            `k1` bigint(11) NULL,
+            `k2` bigint(11) NULL,
+            `c_bool` boolean replace NULL,
+            `c_tinyint` tinyint(4) min NULL,
+            `c_smallint` smallint(6) max NULL,
+            `c_int` int(11) max NULL,
+            `c_bigint` bigint(20) sum NULL,
+            `c_largeint` largeint(40) min NULL,
+            `c_float` float min NULL,
+            `c_double` double max NULL,
+            `c_decimal` decimal(20, 3) sum NULL,
+            `c_decimalv3` decimalv3(20, 3) sum NULL,
+            `c_date` date replace NULL,
+            `c_datetime` datetime replace NULL,
+            `c_datev2` datev2 replace NULL,
+            `c_datetimev2` datetimev2(0)replace NULL,
+            `c_char` char(15) replace NULL,
+            `c_varchar` varchar(100) replace NULL,
+            `c_string` text replace NULL
+        ) ENGINE=OLAP
+        AGGREGATE KEY(`k1`, `k2`)
+        COMMENT 'OLAP'
+        DISTRIBUTED BY HASH(`k1`) BUCKETS 1
+        PROPERTIES("replication_num" = "1");
+        """
+
+    // load data
+    streamLoad {
+        table testTable
+        file dataFile
+        time 60000
+
+        check { result, exception, startTime, endTime ->
+            if (exception != null) {
+                throw exception
+            }
+            log.info("Stream load result: ${result}".toString())
+            def json = parseJson(result)
+        }
+    }
+    createMV ("""CREATE MATERIALIZED VIEW mv_${testTable}_1 AS SELECT k2, k1, 
max(c_int) FROM ${testTable} GROUP BY k2, k1""")
+    qt_sql """ desc ${testTable} all """
+    sql "set topn_opt_limit_threshold = 100"
+    qt_sql "SELECT * from ${testTable} order by 1, 2, 3 limit 10"
+    qt_sql "SELECT * from ${testTable} where c_tinyint = 10 order by 1, 2, 3 
limit 10 "
+
+    sql """
+          ALTER table ${testTable} MODIFY COLUMN c_int BIGINT max;
+          """
+    def getJobState = { tableName ->
+          def jobStateResult = sql """  SHOW ALTER TABLE COLUMN WHERE 
IndexName='${tableName}' ORDER BY createtime DESC LIMIT 1 """
+          return jobStateResult[0][9]
+     }
+    int max_try_time = 100
+    while (max_try_time--){
+        String result = getJobState(testTable)
+        if (result == "FINISHED") {
+            break
+        } else {
+            sleep(2000)
+            if (max_try_time < 1){
+                assertEquals(1,2)
+            }
+        }
+    }
+    qt_sql """ desc ${testTable} all """
+    sql "INSERT INTO ${testTable} SELECT * from ${testTable}"
+}


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


Reply via email to