You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2023/11/24 04:34:47 UTC

(doris) branch master updated: [feature](mtmv)(3)Implementing multi table materialized views (#26146)

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

morningman 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 dfe3a2dd015 [feature](mtmv)(3)Implementing multi table materialized views (#26146)
dfe3a2dd015 is described below

commit dfe3a2dd015e8fd0a47e3ad21a1adac65038846d
Author: zhangdong <49...@qq.com>
AuthorDate: Fri Nov 24 12:34:38 2023 +0800

    [feature](mtmv)(3)Implementing multi table materialized views (#26146)
    
    Introduction to Main Classes:
    - MTMVService:MTMV services for other modules to call
    - MTMVHookService:All operations that affect the MTMV
      - MTMVJobManager:All operations that affect the MTMV job
      - MTMVCacheManager:All operations that affect the MTMV Cache
    - MTMVTask&MTMVJob:Inherit from job framework
---
 be/src/vec/exec/scan/vmeta_scanner.cpp             |  24 ++
 be/src/vec/exec/scan/vmeta_scanner.h               |   2 +
 .../main/java/org/apache/doris/common/Config.java  |  15 +-
 fe/fe-core/src/main/cup/sql_parser.cup             |  24 +-
 .../main/java/org/apache/doris/alter/Alter.java    |  77 +++--
 .../java/org/apache/doris/alter/AlterOpType.java   |   5 +
 .../org/apache/doris/alter/AlterOperations.java    |   8 +
 .../org/apache/doris/analysis/CreateJobStmt.java   |   8 +-
 .../org/apache/doris/analysis/CreateMTMVStmt.java  |  62 ++++
 .../org/apache/doris/analysis/CreateTableStmt.java |   4 +-
 .../doris/analysis/DropMaterializedViewStmt.java   |  62 +---
 .../org/apache/doris/analysis/ShowJobStmt.java     |  35 +--
 .../org/apache/doris/analysis/ShowJobTaskStmt.java |  34 +--
 .../java/org/apache/doris/catalog/Database.java    |   5 +
 .../main/java/org/apache/doris/catalog/Env.java    | 109 ++++---
 .../main/java/org/apache/doris/catalog/MTMV.java   | 171 ++++++++++-
 .../org/apache/doris/catalog/OlapTableFactory.java |  88 +++++-
 .../apache/doris/common/util/PropertyAnalyzer.java |   1 +
 .../apache/doris/datasource/InternalCatalog.java   |  23 +-
 .../org/apache/doris/job/base/AbstractJob.java     |  84 ++++--
 .../main/java/org/apache/doris/job/base/Job.java   |  11 +-
 .../doris/job/base/JobExecutionConfiguration.java  |  24 +-
 .../org/apache/doris/job/base/TimerDefinition.java |  10 +-
 .../doris/job/extensions/insert/InsertJob.java     | 121 ++++++--
 .../doris/job/extensions/insert/InsertTask.java    | 148 ++++++++--
 .../apache/doris/job/extensions/mtmv/MTMVJob.java  | 152 ++++++++++
 .../apache/doris/job/extensions/mtmv/MTMVTask.java | 169 +++++++++++
 .../org/apache/doris/job/manager/JobManager.java   |  59 ++--
 .../job/manager/TaskDisruptorGroupManager.java     |  25 +-
 .../apache/doris/job/scheduler/JobScheduler.java   |  11 +-
 .../org/apache/doris/job/task/AbstractTask.java    |  29 +-
 .../main/java/org/apache/doris/job/task/Task.java  |  19 +-
 .../org/apache/doris/journal/JournalEntity.java    |   6 +
 .../java/org/apache/doris/load/EtlJobType.java     |   2 +
 .../apache/doris/load/loadv2/BrokerLoadJob.java    |   2 +-
 .../apache/doris/load/loadv2/InsertLoadJob.java    |  22 ++
 .../java/org/apache/doris/load/loadv2/LoadJob.java |  15 +-
 .../org/apache/doris/load/loadv2/LoadManager.java  |  34 ++-
 .../org/apache/doris/load/loadv2/SparkLoadJob.java |   2 +-
 .../java/org/apache/doris/mtmv/BaseTableInfo.java  |  91 ++++++
 .../main/java/org/apache/doris/mtmv/EnvInfo.java   |  30 +-
 .../EtlJobType.java => mtmv/MTMVAlterOpType.java}  |  16 +-
 .../org/apache/doris/mtmv/MTMVCacheManager.java    | 312 +++++++++++++++++++++
 .../org/apache/doris/mtmv/MTMVHookService.java     | 104 +++++++
 .../java/org/apache/doris/mtmv/MTMVJobInfo.java    |  63 +++++
 .../java/org/apache/doris/mtmv/MTMVJobManager.java | 195 +++++++++++++
 .../org/apache/doris/mtmv/MTMVRefreshEnum.java     |   1 -
 .../doris/mtmv/{EnvInfo.java => MTMVRelation.java} |  43 +--
 .../java/org/apache/doris/mtmv/MTMVService.java    | 136 +++++++++
 .../java/org/apache/doris/mtmv/MTMVStatus.java     |  97 +++++++
 .../trees/plans/commands/CreateMTMVCommand.java    |   4 +-
 .../trees/plans/commands/DropMTMVCommand.java      |   4 +-
 .../plans/commands/InsertIntoTableCommand.java     |  13 +-
 .../trees/plans/commands/RefreshMTMVCommand.java   |   4 +-
 .../plans/commands/info/AlterMTMVPropertyInfo.java |  22 +-
 .../plans/commands/info/AlterMTMVRefreshInfo.java  |   3 +-
 .../plans/commands/info/AlterMTMVRenameInfo.java   |   8 +-
 .../plans/commands/info/ColumnDefinition.java      |   4 +
 .../trees/plans/commands/info/CreateMTMVInfo.java  | 151 +++++++++-
 .../trees/plans/commands/info/DropMTMVInfo.java    |  24 ++
 .../trees/plans/commands/info/RefreshMTMVInfo.java |  12 +
 .../org/apache/doris/nereids/txn/Transaction.java  |  19 +-
 .../java/org/apache/doris/persist/AlterMTMV.java   | 150 ++++++++++
 .../java/org/apache/doris/persist/EditLog.java     |   9 +
 .../org/apache/doris/persist/OperationType.java    |   2 +
 .../org/apache/doris/persist/gson/GsonUtils.java   |   7 +-
 .../main/java/org/apache/doris/qe/DdlExecutor.java |  25 +-
 .../java/org/apache/doris/qe/SessionVariable.java  |  23 ++
 .../java/org/apache/doris/qe/ShowExecutor.java     |  38 +--
 .../java/org/apache/doris/qe/StmtExecutor.java     |   2 +-
 .../MaterializedViewsTableValuedFunction.java      | 117 ++++++++
 .../doris/tablefunction/MetadataGenerator.java     |  47 ++++
 .../tablefunction/MetadataTableValuedFunction.java |   2 +
 .../doris/tablefunction/TableValuedFunctionIf.java |   2 +
 gensrc/thrift/FrontendService.thrift               |   1 +
 gensrc/thrift/PlanNodes.thrift                     |   8 +-
 gensrc/thrift/Types.thrift                         |   1 +
 regression-test/data/mtmv_p0/test_base_mtmv.out    |  19 ++
 regression-test/data/mtmv_p0/test_build_mtmv.out   |  61 ++++
 regression-test/data/mtmv_p0/test_create_mtmv.out  |   6 +
 .../org/apache/doris/regression/suite/Suite.groovy |  41 +++
 .../suites/job_p0/test_base_insert_job.groovy      | 111 ++++++++
 .../suites/mtmv_p0/test_base_mtmv.groovy           |  96 +++++++
 .../suites/mtmv_p0/test_build_mtmv.groovy          | 279 ++++++++++++++++++
 84 files changed, 3705 insertions(+), 400 deletions(-)

diff --git a/be/src/vec/exec/scan/vmeta_scanner.cpp b/be/src/vec/exec/scan/vmeta_scanner.cpp
index 66d4138d48f..3a3473fa164 100644
--- a/be/src/vec/exec/scan/vmeta_scanner.cpp
+++ b/be/src/vec/exec/scan/vmeta_scanner.cpp
@@ -231,6 +231,9 @@ Status VMetaScanner::_fetch_metadata(const TMetaScanRange& meta_scan_range) {
     case TMetadataType::CATALOGS:
         RETURN_IF_ERROR(_build_catalogs_metadata_request(meta_scan_range, &request));
         break;
+    case TMetadataType::MATERIALIZED_VIEWS:
+        RETURN_IF_ERROR(_build_materialized_views_metadata_request(meta_scan_range, &request));
+        break;
     case TMetadataType::QUERIES:
         RETURN_IF_ERROR(_build_queries_metadata_request(meta_scan_range, &request));
         break;
@@ -375,6 +378,27 @@ Status VMetaScanner::_build_catalogs_metadata_request(const TMetaScanRange& meta
     return Status::OK();
 }
 
+Status VMetaScanner::_build_materialized_views_metadata_request(
+        const TMetaScanRange& meta_scan_range, TFetchSchemaTableDataRequest* request) {
+    VLOG_CRITICAL << "VMetaScanner::_build_materialized_views_metadata_request";
+    if (!meta_scan_range.__isset.materialized_views_params) {
+        return Status::InternalError(
+                "Can not find TMaterializedViewsMetadataParams from meta_scan_range.");
+    }
+
+    // create request
+    request->__set_schema_table_name(TSchemaTableName::METADATA_TABLE);
+
+    // create TMetadataTableRequestParams
+    TMetadataTableRequestParams metadata_table_params;
+    metadata_table_params.__set_metadata_type(TMetadataType::MATERIALIZED_VIEWS);
+    metadata_table_params.__set_materialized_views_metadata_params(
+            meta_scan_range.materialized_views_params);
+
+    request->__set_metada_table_params(metadata_table_params);
+    return Status::OK();
+}
+
 Status VMetaScanner::_build_queries_metadata_request(const TMetaScanRange& meta_scan_range,
                                                      TFetchSchemaTableDataRequest* request) {
     VLOG_CRITICAL << "VMetaScanner::_build_queries_metadata_request";
diff --git a/be/src/vec/exec/scan/vmeta_scanner.h b/be/src/vec/exec/scan/vmeta_scanner.h
index 6c364b94fe2..e6eb32e81b2 100644
--- a/be/src/vec/exec/scan/vmeta_scanner.h
+++ b/be/src/vec/exec/scan/vmeta_scanner.h
@@ -81,6 +81,8 @@ private:
                                                    TFetchSchemaTableDataRequest* request);
     Status _build_catalogs_metadata_request(const TMetaScanRange& meta_scan_range,
                                             TFetchSchemaTableDataRequest* request);
+    Status _build_materialized_views_metadata_request(const TMetaScanRange& meta_scan_range,
+                                                      TFetchSchemaTableDataRequest* request);
     Status _build_queries_metadata_request(const TMetaScanRange& meta_scan_range,
                                            TFetchSchemaTableDataRequest* request);
     bool _meta_eos;
diff --git a/fe/fe-common/src/main/java/org/apache/doris/common/Config.java b/fe/fe-common/src/main/java/org/apache/doris/common/Config.java
index e25ce96ff88..df2cafa4c09 100644
--- a/fe/fe-common/src/main/java/org/apache/doris/common/Config.java
+++ b/fe/fe-common/src/main/java/org/apache/doris/common/Config.java
@@ -1586,15 +1586,16 @@ public class Config extends ConfigBase {
     @ConfField(description = {"任务堆积时用于存放定时任务的队列大小", "The number of timer jobs that can be queued."})
     public static int job_dispatch_timer_job_queue_size = 1024;
 
-    /**
-     * The number of threads used to consume insert tasks.
-     * if you have a lot of insert jobs,and the average execution frequency is relatively high you need to increase
-     * this value or increase the number of {@code @job_insert_task_queue_size}
-     * The value should be greater than 0, if it is 0 or <=0, set it to 5
-     */
-    @ConfField(description = {"用于执行 Insert 任务的线程数", "The number of threads used to consume insert tasks."})
+    @ConfField(description = {"用于执行 Insert 任务的线程数,值应该大于0,否则默认为5",
+            "The number of threads used to consume Insert tasks, "
+                    + "the value should be greater than 0, if it is <=0, default is 5."})
     public static int job_insert_task_consumer_thread_num = 10;
 
+    @ConfField(description = {"用于执行 MTMV 任务的线程数,值应该大于0,否则默认为5",
+            "The number of threads used to consume mtmv tasks, "
+                    + "the value should be greater than 0, if it is <=0, default is 5."})
+    public static int job_mtmv_task_consumer_thread_num = 10;
+
     /*---------------------- JOB CONFIG END------------------------*/
     /**
      * The number of async tasks that can be queued. @See TaskDisruptor
diff --git a/fe/fe-core/src/main/cup/sql_parser.cup b/fe/fe-core/src/main/cup/sql_parser.cup
index ee65d926e85..9f182168509 100644
--- a/fe/fe-core/src/main/cup/sql_parser.cup
+++ b/fe/fe-core/src/main/cup/sql_parser.cup
@@ -2595,16 +2595,28 @@ resume_job_stmt ::=
 show_job_stmt ::=
     KW_SHOW KW_JOBS
     {:
-        RESULT = new ShowJobStmt(null,null,null);
+        RESULT = new ShowJobStmt(null,null);
     :}
-    | KW_SHOW  KW_JOB KW_FOR job_label:jobLabel
+    | KW_SHOW KW_MTMV KW_JOBS
+    {:
+        RESULT = new ShowJobStmt(null,org.apache.doris.job.common.JobType.MTMV);
+    :}
+    | KW_SHOW KW_MTMV KW_JOB KW_FOR job_label:jobLabel
     {:
-        RESULT = new ShowJobStmt(null,jobLabel,null);
+        RESULT = new ShowJobStmt(jobLabel,org.apache.doris.job.common.JobType.MTMV);
     :}
+    | KW_SHOW  KW_JOB KW_FOR job_label:jobLabel
+    {:
+        RESULT = new ShowJobStmt(jobLabel,org.apache.doris.job.common.JobType.INSERT);
+    :}    
     | KW_SHOW KW_JOB KW_TASKS KW_FOR job_label:jobLabel
     {:
-        RESULT = new ShowJobTaskStmt(null,jobLabel);
+        RESULT = new ShowJobTaskStmt(jobLabel,org.apache.doris.job.common.JobType.INSERT);
     :}    
+    | KW_SHOW KW_MTMV KW_JOB KW_TASKS KW_FOR job_label:jobLabel
+    {:
+        RESULT = new ShowJobTaskStmt(jobLabel,org.apache.doris.job.common.JobType.MTMV);
+    :}       
     ;
 pause_job_stmt ::=
     KW_PAUSE KW_JOB KW_FOR job_label:jobLabel
@@ -2978,10 +2990,6 @@ drop_stmt ::=
     {:
         RESULT = new AlterTableStmt(tableName, Lists.newArrayList(new DropIndexClause(indexName, ifExists, tableName, false)));
     :}
-    | KW_DROP KW_MATERIALIZED KW_VIEW opt_if_exists:ifExists table_name:mvName
-    {:
-        RESULT = new DropMaterializedViewStmt(ifExists, mvName);
-    :}
     | KW_DROP KW_MATERIALIZED KW_VIEW opt_if_exists:ifExists ident:mvName KW_ON table_name:tableName
     {:
         RESULT = new DropMaterializedViewStmt(ifExists, mvName, tableName);
diff --git a/fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java b/fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java
index fdc27bb62d1..1cc679740e1 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java
@@ -28,7 +28,6 @@ import org.apache.doris.analysis.CreateMaterializedViewStmt;
 import org.apache.doris.analysis.DropMaterializedViewStmt;
 import org.apache.doris.analysis.DropPartitionClause;
 import org.apache.doris.analysis.DropPartitionFromIndexClause;
-import org.apache.doris.analysis.DropTableStmt;
 import org.apache.doris.analysis.ModifyColumnCommentClause;
 import org.apache.doris.analysis.ModifyDistributionClause;
 import org.apache.doris.analysis.ModifyEngineClause;
@@ -45,6 +44,7 @@ import org.apache.doris.catalog.Column;
 import org.apache.doris.catalog.DataProperty;
 import org.apache.doris.catalog.Database;
 import org.apache.doris.catalog.Env;
+import org.apache.doris.catalog.MTMV;
 import org.apache.doris.catalog.MysqlTable;
 import org.apache.doris.catalog.OdbcTable;
 import org.apache.doris.catalog.OlapTable;
@@ -62,6 +62,8 @@ import org.apache.doris.common.UserException;
 import org.apache.doris.common.util.DynamicPartitionUtil;
 import org.apache.doris.common.util.MetaLockUtils;
 import org.apache.doris.common.util.PropertyAnalyzer;
+import org.apache.doris.nereids.trees.plans.commands.info.TableNameInfo;
+import org.apache.doris.persist.AlterMTMV;
 import org.apache.doris.persist.AlterViewInfo;
 import org.apache.doris.persist.BatchModifyPartitionsInfo;
 import org.apache.doris.persist.ModifyCommentOperationLog;
@@ -120,26 +122,13 @@ public class Alter {
     }
 
     public void processDropMaterializedView(DropMaterializedViewStmt stmt) throws DdlException, MetaNotFoundException {
-        if (!stmt.isForMTMV() && stmt.getTableName() == null) {
-            throw new DdlException("Drop materialized view without table name is unsupported : " + stmt.toSql());
-        }
-
-        // drop materialized view
-        if (!stmt.isForMTMV()) {
-            TableName tableName = stmt.getTableName();
-
-            // check db
-            String dbName = tableName.getDb();
-            Database db = Env.getCurrentInternalCatalog().getDbOrDdlException(dbName);
+        TableName tableName = stmt.getTableName();
+        String dbName = tableName.getDb();
+        Database db = Env.getCurrentInternalCatalog().getDbOrDdlException(dbName);
 
-            String name = tableName.getTbl();
-            OlapTable olapTable = (OlapTable) db.getTableOrMetaException(name, TableType.OLAP);
-            ((MaterializedViewHandler) materializedViewHandler).processDropMaterializedView(stmt, db, olapTable);
-        } else {
-            DropTableStmt dropTableStmt = new DropTableStmt(stmt.isIfExists(), stmt.getMTMVName(), false);
-            dropTableStmt.setMaterializedView(true);
-            Env.getCurrentInternalCatalog().dropTable(dropTableStmt);
-        }
+        String name = tableName.getTbl();
+        OlapTable olapTable = (OlapTable) db.getTableOrMetaException(name, TableType.OLAP);
+        ((MaterializedViewHandler) materializedViewHandler).processDropMaterializedView(stmt, db, olapTable);
     }
 
     private boolean processAlterOlapTable(AlterTableStmt stmt, OlapTable olapTable, List<AlterClause> alterClauses,
@@ -155,6 +144,10 @@ public class Alter {
         AlterOperations currentAlterOps = new AlterOperations();
         currentAlterOps.checkConflict(alterClauses);
 
+        if (olapTable instanceof MTMV) {
+            currentAlterOps.checkMTMVAllow(alterClauses);
+        }
+
         // check cluster capacity and db quota, only need to check once.
         if (currentAlterOps.needCheckCapacity()) {
             Env.getCurrentSystemInfo().checkAvailableCapacity();
@@ -201,6 +194,8 @@ public class Alter {
         } else if (currentAlterOps.hasSchemaChangeOp()) {
             // if modify storage type to v2, do schema change to convert all related tablets to segment v2 format
             schemaChangeHandler.process(stmt.toSql(), alterClauses, clusterName, db, olapTable);
+            // if base table schemaChanged, need change mtmv status
+            Env.getCurrentEnv().getMtmvService().alterTable(olapTable);
         } else if (currentAlterOps.hasRollupOp()) {
             materializedViewHandler.process(alterClauses, clusterName, db, olapTable);
         } else if (currentAlterOps.hasPartitionOp()) {
@@ -256,6 +251,7 @@ public class Alter {
             }
         } else if (currentAlterOps.hasRenameOp()) {
             processRename(db, olapTable, alterClauses);
+            Env.getCurrentEnv().getMtmvService().alterTable(olapTable);
         } else if (currentAlterOps.hasReplaceTableOp()) {
             processReplaceTable(db, olapTable, alterClauses);
         } else if (currentAlterOps.contains(AlterOpType.MODIFY_TABLE_PROPERTY_SYNC)) {
@@ -877,4 +873,45 @@ public class Alter {
     public AlterHandler getClusterHandler() {
         return clusterHandler;
     }
+
+    public void processAlterMTMV(AlterMTMV alterMTMV, boolean isReplay) {
+        TableNameInfo tbl = alterMTMV.getMvName();
+        MTMV mtmv = null;
+        try {
+            Database db = Env.getCurrentInternalCatalog().getDbOrDdlException(tbl.getDb());
+            mtmv = (MTMV) db.getTableOrMetaException(tbl.getTbl(), TableType.MATERIALIZED_VIEW);
+
+            mtmv.writeLock();
+            switch (alterMTMV.getOpType()) {
+                case ALTER_REFRESH_INFO:
+                    mtmv.alterRefreshInfo(alterMTMV.getRefreshInfo());
+                    break;
+                case ALTER_STATUS:
+                    mtmv.alterStatus(alterMTMV.getStatus());
+                    break;
+                case ALTER_PROPERTY:
+                    mtmv.alterMvProperties(alterMTMV.getMvProperties());
+                    break;
+                case ADD_TASK:
+                    mtmv.addTaskResult(alterMTMV.getTask(), alterMTMV.getRelation());
+                    Env.getCurrentEnv().getMtmvService()
+                            .refreshComplete(mtmv, alterMTMV.getRelation(), alterMTMV.getTask());
+                    break;
+                default:
+                    throw new RuntimeException("Unknown type value: " + alterMTMV.getOpType());
+            }
+            // 4. log it and replay it in the follower
+            if (!isReplay) {
+                Env.getCurrentEnv().getMtmvService().alterMTMV(mtmv, alterMTMV);
+                Env.getCurrentEnv().getEditLog().logAlterMTMV(alterMTMV);
+            }
+        } catch (UserException e) {
+            // if MTMV has been dropped, ignore this exception
+            LOG.warn(e);
+        } finally {
+            if (mtmv != null) {
+                mtmv.writeUnlock();
+            }
+        }
+    }
 }
diff --git a/fe/fe-core/src/main/java/org/apache/doris/alter/AlterOpType.java b/fe/fe-core/src/main/java/org/apache/doris/alter/AlterOpType.java
index 9563eaa8947..270132c1e17 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/alter/AlterOpType.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/alter/AlterOpType.java
@@ -71,4 +71,9 @@ public enum AlterOpType {
         return this == ADD_ROLLUP || this == SCHEMA_CHANGE || this == ADD_PARTITION || this == ENABLE_FEATURE;
     }
 
+    public boolean mtmvAllowOp() {
+        return this == MODIFY_TABLE_PROPERTY || this == MODIFY_DISTRIBUTION || this == MODIFY_TABLE_COMMENT
+                || this == ADD_PARTITION || this == DROP_PARTITION || this == REPLACE_PARTITION
+                || this == MODIFY_PARTITION;
+    }
 }
diff --git a/fe/fe-core/src/main/java/org/apache/doris/alter/AlterOperations.java b/fe/fe-core/src/main/java/org/apache/doris/alter/AlterOperations.java
index 5742c631de2..a6fefb119c8 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/alter/AlterOperations.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/alter/AlterOperations.java
@@ -48,6 +48,14 @@ public class AlterOperations {
         }
     }
 
+    public void checkMTMVAllow(List<AlterClause> alterClauses) throws DdlException {
+        for (AlterClause alterClause : alterClauses) {
+            if (!alterClause.getOpType().mtmvAllowOp()) {
+                throw new DdlException("Alter operation " + alterClause.getOpType() + " Not allowed to MTMV");
+            }
+        }
+    }
+
     // some operations take up disk space. so we need to check the disk capacity before processing.
     // return true if we see these kind of operations.
     public boolean needCheckCapacity() {
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateJobStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateJobStmt.java
index d2aed10983f..a1c008fb95e 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateJobStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateJobStmt.java
@@ -83,8 +83,6 @@ public class CreateJobStmt extends DdlStmt {
     private final String comment;
     private JobExecuteType executeType;
 
-    private String timezone = TimeUtils.DEFAULT_TIME_ZONE;
-
     private static final ImmutableSet<Class<? extends DdlStmt>> supportStmtSuperClass
             = new ImmutableSet.Builder<Class<? extends DdlStmt>>().add(InsertStmt.class)
             .add(UpdateStmt.class).build();
@@ -114,7 +112,7 @@ public class CreateJobStmt extends DdlStmt {
         Env.getCurrentInternalCatalog().getDbOrAnalysisException(dbName);
         analyzerSqlStmt();
         // check its insert stmt,currently only support insert stmt
-        //todo used InsertIntoCommand if job is InsertJob
+        //todo when support other stmt,need to check stmt type and generate jobInstance
         InsertJob job = new InsertJob();
         JobExecutionConfiguration jobExecutionConfiguration = new JobExecutionConfiguration();
         jobExecutionConfiguration.setExecuteType(executeType);
@@ -144,10 +142,12 @@ public class CreateJobStmt extends DdlStmt {
         job.setJobName(labelName.getLabelName());
         job.setCreateUser(ConnectContext.get().getCurrentUserIdentity());
         job.setJobStatus(JobStatus.RUNNING);
-        job.checkJobParams();
+        job.setJobId(Env.getCurrentEnv().getNextId());
         String originStmt = getOrigStmt().originStmt;
         String executeSql = parseExecuteSql(originStmt);
         job.setExecuteSql(executeSql);
+
+        //job.checkJobParams();
         jobInstance = job;
     }
 
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateMTMVStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateMTMVStmt.java
new file mode 100644
index 00000000000..bb2efdd6281
--- /dev/null
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateMTMVStmt.java
@@ -0,0 +1,62 @@
+// 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.
+
+package org.apache.doris.analysis;
+
+import org.apache.doris.catalog.Column;
+import org.apache.doris.catalog.Index;
+import org.apache.doris.mtmv.EnvInfo;
+import org.apache.doris.mtmv.MTMVRefreshInfo;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public class CreateMTMVStmt extends CreateTableStmt {
+    private final MTMVRefreshInfo refreshInfo;
+    private final String querySql;
+    private final EnvInfo envInfo;
+    private Map<String, String> mvProperties;
+
+    public CreateMTMVStmt(boolean ifNotExists, TableName mvName, List<Column> columns,
+            MTMVRefreshInfo refreshInfo, KeysDesc keyDesc, DistributionDesc distributionDesc,
+            Map<String, String> properties, Map<String, String> mvProperties, String querySql, String comment,
+            EnvInfo envInfo) {
+        super(ifNotExists, false, mvName, columns, new ArrayList<Index>(), DEFAULT_ENGINE_NAME, keyDesc, null,
+                distributionDesc, properties, null, comment, null, null);
+        this.refreshInfo = refreshInfo;
+        this.querySql = querySql;
+        this.envInfo = envInfo;
+        this.mvProperties = mvProperties;
+    }
+
+    public MTMVRefreshInfo getRefreshInfo() {
+        return refreshInfo;
+    }
+
+    public String getQuerySql() {
+        return querySql;
+    }
+
+    public EnvInfo getEnvInfo() {
+        return envInfo;
+    }
+
+    public Map<String, String> getMvProperties() {
+        return mvProperties;
+    }
+}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateTableStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateTableStmt.java
index aecee1465d5..a2ae5547baf 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateTableStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateTableStmt.java
@@ -67,7 +67,7 @@ public class CreateTableStmt extends DdlStmt {
 
     protected static final String DEFAULT_ENGINE_NAME = "olap";
 
-    private boolean ifNotExists;
+    protected boolean ifNotExists;
     private boolean isExternal;
     protected TableName tableName;
     protected List<ColumnDef> columnDefs;
@@ -244,7 +244,7 @@ public class CreateTableStmt extends DdlStmt {
         this.extProperties = extProperties;
         this.columnDefs = Lists.newArrayList();
         this.comment = Strings.nullToEmpty(comment);
-        this.rollupAlterClauseList = rollupAlterClauseList;
+        this.rollupAlterClauseList = (rollupAlterClauseList == null) ? Lists.newArrayList() : rollupAlterClauseList;
     }
 
     public void addColumnDef(ColumnDef columnDef) {
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/DropMaterializedViewStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/DropMaterializedViewStmt.java
index 6c8e58b259f..68cd29688d5 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/DropMaterializedViewStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/DropMaterializedViewStmt.java
@@ -41,8 +41,6 @@ public class DropMaterializedViewStmt extends DdlStmt {
 
     private String mvName;
     private TableName tableName;
-
-    private TableName mtmvName;
     private boolean ifExists;
 
     public DropMaterializedViewStmt(boolean ifExists, String mvName, TableName tableName) {
@@ -51,59 +49,31 @@ public class DropMaterializedViewStmt extends DdlStmt {
         this.ifExists = ifExists;
     }
 
-    public DropMaterializedViewStmt(boolean ifExists, TableName mvName) {
-        this.mtmvName = mvName;
-        this.ifExists = ifExists;
-        this.tableName = null;
-    }
-
     public String getMvName() {
-        if (tableName != null) {
-            return mvName;
-        } else if (mtmvName != null) {
-            return mtmvName.toString();
-        } else {
-            return null;
-        }
+        return mvName;
     }
 
     public TableName getTableName() {
         return tableName;
     }
 
-    public TableName getMTMVName() {
-        return mtmvName;
-    }
-
     public boolean isIfExists() {
         return ifExists;
     }
 
-    public boolean isForMTMV() {
-        return mtmvName != null;
-    }
-
     @Override
     public void analyze(Analyzer analyzer) throws UserException {
-        if (!isForMTMV()) {
-            if (Strings.isNullOrEmpty(mvName)) {
-                throw new AnalysisException("The materialized name could not be empty or null.");
-            }
-            tableName.analyze(analyzer);
-            // disallow external catalog
-            Util.prohibitExternalCatalog(tableName.getCtl(), this.getClass().getSimpleName());
-
-            // check access
-            if (!Env.getCurrentEnv().getAccessManager().checkTblPriv(ConnectContext.get(), tableName.getDb(),
-                    tableName.getTbl(), PrivPredicate.DROP)) {
-                ErrorReport.reportAnalysisException(ErrorCode.ERR_SPECIFIC_ACCESS_DENIED_ERROR, "DROP");
-            }
-        } else {
-            mtmvName.analyze(analyzer);
-            if (!Env.getCurrentEnv().getAccessManager().checkTblPriv(ConnectContext.get(), mtmvName.getDb(),
-                    mtmvName.getTbl(), PrivPredicate.DROP)) {
-                ErrorReport.reportAnalysisException(ErrorCode.ERR_SPECIFIC_ACCESS_DENIED_ERROR, "DROP");
-            }
+        if (Strings.isNullOrEmpty(mvName)) {
+            throw new AnalysisException("The materialized name could not be empty or null.");
+        }
+        tableName.analyze(analyzer);
+        // disallow external catalog
+        Util.prohibitExternalCatalog(tableName.getCtl(), this.getClass().getSimpleName());
+
+        // check access
+        if (!Env.getCurrentEnv().getAccessManager().checkTblPriv(ConnectContext.get(), tableName.getDb(),
+                tableName.getTbl(), PrivPredicate.DROP)) {
+            ErrorReport.reportAnalysisException(ErrorCode.ERR_SPECIFIC_ACCESS_DENIED_ERROR, "DROP");
         }
     }
 
@@ -114,12 +84,8 @@ public class DropMaterializedViewStmt extends DdlStmt {
         if (ifExists) {
             stringBuilder.append("IF EXISTS ");
         }
-        if (mtmvName != null) {
-            stringBuilder.append(mtmvName.toSql());
-        } else {
-            stringBuilder.append("`").append(mvName).append("` ");
-            stringBuilder.append("ON ").append(tableName.toSql());
-        }
+        stringBuilder.append("`").append(mvName).append("` ");
+        stringBuilder.append("ON ").append(tableName.toSql());
         return stringBuilder.toString();
     }
 }
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowJobStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowJobStmt.java
index dc4e96e05f0..59c5fc2fc47 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowJobStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowJobStmt.java
@@ -19,18 +19,16 @@ package org.apache.doris.analysis;
 
 import org.apache.doris.catalog.Column;
 import org.apache.doris.catalog.ScalarType;
-import org.apache.doris.cluster.ClusterNamespace;
 import org.apache.doris.common.AnalysisException;
-import org.apache.doris.common.ErrorCode;
-import org.apache.doris.common.ErrorReport;
 import org.apache.doris.common.UserException;
+import org.apache.doris.job.common.JobType;
 import org.apache.doris.qe.ConnectContext;
 import org.apache.doris.qe.ShowResultSetMetaData;
 
-import com.google.common.base.Strings;
 import com.google.common.collect.ImmutableList;
 import lombok.Getter;
 
+import java.util.Arrays;
 import java.util.List;
 
 /**
@@ -63,24 +61,30 @@ public class ShowJobStmt extends ShowStmt {
     @Getter
     private String dbFullName; // optional
 
-    private String jobCategoryName; // optional
+    @Getter
+    private JobType jobType; // optional
+
+    /**
+     * Supported job types, if we want to support more job types, we need to add them here.
+     */
+    @Getter
+    private List<JobType> jobTypes = Arrays.asList(JobType.INSERT); // optional
 
     @Getter
     private String name; // optional
     @Getter
     private String pattern; // optional
 
-    public ShowJobStmt(String category, LabelName labelName, String pattern) {
+    public ShowJobStmt(LabelName labelName, JobType jobType) {
         this.labelName = labelName;
-        this.pattern = pattern;
-        this.jobCategoryName = category;
+        this.jobType = jobType;
+        this.name = labelName == null ? null : labelName.getLabelName();
     }
 
     @Override
     public void analyze(Analyzer analyzer) throws UserException {
         super.analyze(analyzer);
         checkAuth();
-        checkLabelName(analyzer);
     }
 
     private void checkAuth() throws AnalysisException {
@@ -90,19 +94,6 @@ public class ShowJobStmt extends ShowStmt {
         }
     }
 
-    private void checkLabelName(Analyzer analyzer) throws AnalysisException {
-        String dbName = labelName == null ? null : labelName.getDbName();
-        if (Strings.isNullOrEmpty(dbName)) {
-            dbFullName = analyzer.getContext().getDatabase();
-            if (Strings.isNullOrEmpty(dbFullName)) {
-                ErrorReport.reportAnalysisException(ErrorCode.ERR_NO_DB_ERROR);
-            }
-        } else {
-            dbFullName = ClusterNamespace.getFullName(getClusterName(), dbName);
-        }
-        name = labelName == null ? null : labelName.getLabelName();
-    }
-
     public static List<String> getTitleNames() {
         return TITLE_NAMES;
     }
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowJobTaskStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowJobTaskStmt.java
index 8d5c2b61db2..c5688f22b52 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowJobTaskStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowJobTaskStmt.java
@@ -19,14 +19,10 @@ package org.apache.doris.analysis;
 
 import org.apache.doris.catalog.Column;
 import org.apache.doris.catalog.ScalarType;
-import org.apache.doris.cluster.ClusterNamespace;
-import org.apache.doris.common.AnalysisException;
-import org.apache.doris.common.ErrorCode;
-import org.apache.doris.common.ErrorReport;
 import org.apache.doris.common.UserException;
+import org.apache.doris.job.common.JobType;
 import org.apache.doris.qe.ShowResultSetMetaData;
 
-import com.google.common.base.Strings;
 import com.google.common.collect.ImmutableList;
 import lombok.Getter;
 
@@ -49,43 +45,27 @@ public class ShowJobTaskStmt extends ShowStmt {
                     .add("ExecuteSql")
                     .add("Result")
                     .add("ErrorMsg")
-                    .add("TaskType")
                     .build();
 
     @Getter
     private final LabelName labelName;
 
-
-    @Getter
-    private String dbFullName; // optional
     @Getter
     private String name; // optional
 
-    public ShowJobTaskStmt(String category, LabelName labelName) {
+    @Getter
+    JobType jobType;
+
+    public ShowJobTaskStmt(LabelName labelName, JobType jobType) {
         this.labelName = labelName;
+        this.jobType = jobType;
+        this.name = labelName == null ? null : labelName.getLabelName();
     }
 
     @Override
     public void analyze(Analyzer analyzer) throws UserException {
         super.analyze(analyzer);
         CreateJobStmt.checkAuth();
-        checkLabelName(analyzer);
-    }
-
-    private void checkLabelName(Analyzer analyzer) throws AnalysisException {
-        String dbName = labelName == null ? null : labelName.getDbName();
-        if (Strings.isNullOrEmpty(dbName)) {
-            dbFullName = analyzer.getContext().getDatabase();
-            if (Strings.isNullOrEmpty(dbFullName)) {
-                ErrorReport.reportAnalysisException(ErrorCode.ERR_NO_DB_ERROR);
-            }
-        } else {
-            dbFullName = ClusterNamespace.getFullName(getClusterName(), dbName);
-        }
-        if (null == labelName) {
-            throw new AnalysisException("Job name is null");
-        }
-        name = labelName.getLabelName();
     }
 
     public static List<String> getTitleNames() {
diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Database.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/Database.java
index 62d2e0bd6d6..5965ec99650 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Database.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Database.java
@@ -396,6 +396,8 @@ public class Database extends MetaObject implements Writable, DatabaseIf<Table>
                 }
                 if (table.getType() == TableType.ELASTICSEARCH) {
                     Env.getCurrentEnv().getEsRepository().registerTable((EsTable) table);
+                } else if (table.getType() == TableType.MATERIALIZED_VIEW) {
+                    Env.getCurrentEnv().getMtmvService().registerMTMV((MTMV) table, id);
                 }
             }
             return Pair.of(result, isTableExist);
@@ -628,6 +630,9 @@ public class Database extends MetaObject implements Writable, DatabaseIf<Table>
         for (int i = 0; i < numTables; ++i) {
             Table table = Table.read(in);
             table.setQualifiedDbName(fullQualifiedName);
+            if (table instanceof MTMV) {
+                Env.getCurrentEnv().getMtmvService().registerMTMV((MTMV) table, id);
+            }
             String tableName = table.getName();
             nameToTable.put(tableName, table);
             idToTable.put(table.getId(), table);
diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
index 133b10536f7..13e4b615fda 100755
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
@@ -148,6 +148,7 @@ import org.apache.doris.httpv2.entity.ResponseBody;
 import org.apache.doris.httpv2.meta.MetaBaseAction;
 import org.apache.doris.httpv2.rest.RestApiStatusCode;
 import org.apache.doris.job.base.AbstractJob;
+import org.apache.doris.job.extensions.mtmv.MTMVTask;
 import org.apache.doris.job.manager.JobManager;
 import org.apache.doris.journal.JournalCursor;
 import org.apache.doris.journal.JournalEntity;
@@ -175,9 +176,17 @@ import org.apache.doris.master.MetaHelper;
 import org.apache.doris.master.PartitionInMemoryInfoCollector;
 import org.apache.doris.meta.MetaContext;
 import org.apache.doris.metric.MetricRepo;
+import org.apache.doris.mtmv.MTMVAlterOpType;
+import org.apache.doris.mtmv.MTMVRelation;
+import org.apache.doris.mtmv.MTMVService;
+import org.apache.doris.mtmv.MTMVStatus;
 import org.apache.doris.mysql.privilege.AccessControllerManager;
 import org.apache.doris.mysql.privilege.Auth;
 import org.apache.doris.mysql.privilege.PrivPredicate;
+import org.apache.doris.nereids.trees.plans.commands.info.AlterMTMVPropertyInfo;
+import org.apache.doris.nereids.trees.plans.commands.info.AlterMTMVRefreshInfo;
+import org.apache.doris.nereids.trees.plans.commands.info.TableNameInfo;
+import org.apache.doris.persist.AlterMTMV;
 import org.apache.doris.persist.AutoIncrementIdUpdateLog;
 import org.apache.doris.persist.BackendReplicasInfo;
 import org.apache.doris.persist.BackendTabletsInfo;
@@ -494,6 +503,8 @@ public class Env {
 
     private TopicPublisherThread topicPublisherThread;
 
+    private MTMVService mtmvService;
+
     public List<TFrontendInfo> getFrontendInfos() {
         List<TFrontendInfo> res = new ArrayList<>();
 
@@ -720,6 +731,7 @@ public class Env {
         this.queryCancelWorker = new QueryCancelWorker(systemInfo);
         this.topicPublisherThread = new TopicPublisherThread(
                 "TopicPublisher", Config.publish_topic_info_interval_ms, systemInfo);
+        this.mtmvService = new MTMVService();
     }
 
     public static void destroyCheckpoint() {
@@ -775,6 +787,10 @@ public class Env {
         return accessManager;
     }
 
+    public MTMVService getMtmvService() {
+        return mtmvService;
+    }
+
     public TabletScheduler getTabletScheduler() {
         return tabletScheduler;
     }
@@ -2950,48 +2966,47 @@ public class Env {
                 || table.getType() == TableType.HIVE || table.getType() == TableType.JDBC) {
             sb.append("EXTERNAL ");
         }
-        sb.append(table.getType() != TableType.MATERIALIZED_VIEW ? "TABLE " : "MATERIALIZED VIEW ");
+        sb.append("TABLE ");
 
         if (!Strings.isNullOrEmpty(dbName)) {
             sb.append("`").append(dbName).append("`.");
         }
         sb.append("`").append(table.getName()).append("`");
 
-        if (table.getType() != TableType.MATERIALIZED_VIEW) {
-            sb.append(" (\n");
-            int idx = 0;
-            List<Column> columns;
-            // when 'create table B like A', always return schema of A without hidden columns
-            if (getDdlForLike) {
-                columns = table.getBaseSchema(false);
+
+        sb.append(" (\n");
+        int idx = 0;
+        List<Column> columns;
+        // when 'create table B like A', always return schema of A without hidden columns
+        if (getDdlForLike) {
+            columns = table.getBaseSchema(false);
+        } else {
+            columns = table.getBaseSchema();
+        }
+        for (Column column : columns) {
+            if (idx++ != 0) {
+                sb.append(",\n");
+            }
+            // There MUST BE 2 space in front of each column description line
+            // sqlalchemy requires this to parse SHOW CREATE TABLE stmt.
+            if (table.getType() == TableType.OLAP) {
+                sb.append("  ").append(
+                        column.toSql(((OlapTable) table).getKeysType() == KeysType.UNIQUE_KEYS, true));
             } else {
-                columns = table.getBaseSchema();
+                sb.append("  ").append(column.toSql());
             }
-            for (Column column : columns) {
-                if (idx++ != 0) {
+        }
+        if (table.getType() == TableType.OLAP) {
+            OlapTable olapTable = (OlapTable) table;
+            if (CollectionUtils.isNotEmpty(olapTable.getIndexes())) {
+                for (Index index : olapTable.getIndexes()) {
                     sb.append(",\n");
-                }
-                // There MUST BE 2 space in front of each column description line
-                // sqlalchemy requires this to parse SHOW CREATE TABLE stmt.
-                if (table.getType() == TableType.OLAP) {
-                    sb.append("  ").append(
-                            column.toSql(((OlapTable) table).getKeysType() == KeysType.UNIQUE_KEYS, true));
-                } else {
-                    sb.append("  ").append(column.toSql());
-                }
-            }
-            if (table.getType() == TableType.OLAP) {
-                OlapTable olapTable = (OlapTable) table;
-                if (CollectionUtils.isNotEmpty(olapTable.getIndexes())) {
-                    for (Index index : olapTable.getIndexes()) {
-                        sb.append(",\n");
-                        sb.append("  ").append(index.toSql());
-                    }
+                    sb.append("  ").append(index.toSql());
                 }
             }
-            sb.append("\n) ENGINE=");
-            sb.append(table.getType().name());
         }
+        sb.append("\n) ENGINE=");
+        sb.append(table.getType().name());
 
         if (table.getType() == TableType.OLAP || table.getType() == TableType.MATERIALIZED_VIEW) {
             OlapTable olapTable = (OlapTable) table;
@@ -4062,8 +4077,12 @@ public class Env {
         getBackupHandler().cancel(stmt);
     }
 
-    // entry of rename table operation
     public void renameTable(Database db, Table table, TableRenameClause tableRenameClause) throws DdlException {
+        renameTable(db, table, tableRenameClause.getNewTableName());
+    }
+
+    // entry of rename table operation
+    public void renameTable(Database db, Table table, String newTableName) throws DdlException {
         db.writeLockOrDdlException();
         try {
             table.writeLockOrDdlException();
@@ -4074,7 +4093,6 @@ public class Env {
                 }
 
                 String oldTableName = table.getName();
-                String newTableName = tableRenameClause.getNewTableName();
                 if (Env.isStoredTableNamesLowerCase() && !Strings.isNullOrEmpty(newTableName)) {
                     newTableName = newTableName.toLowerCase();
                 }
@@ -5248,7 +5266,8 @@ public class Env {
         long dbId = replaceTempPartitionLog.getDbId();
         long tableId = replaceTempPartitionLog.getTblId();
         Database db = getInternalCatalog().getDbOrMetaException(dbId);
-        OlapTable olapTable = (OlapTable) db.getTableOrMetaException(tableId, TableType.OLAP);
+        OlapTable olapTable = (OlapTable) db
+                .getTableOrMetaException(tableId, Lists.newArrayList(TableType.OLAP, TableType.MATERIALIZED_VIEW));
         olapTable.writeLock();
         try {
             olapTable.replaceTempPartitions(replaceTempPartitionLog.getPartitions(),
@@ -5763,4 +5782,28 @@ public class Env {
     public StatisticsAutoCollector getStatisticsAutoCollector() {
         return statisticsAutoCollector;
     }
+
+    public void alterMTMVRefreshInfo(AlterMTMVRefreshInfo info) {
+        AlterMTMV alter = new AlterMTMV(info.getMvName(), info.getRefreshInfo(), MTMVAlterOpType.ALTER_REFRESH_INFO);
+        this.alter.processAlterMTMV(alter, false);
+    }
+
+    public void alterMTMVProperty(AlterMTMVPropertyInfo info) {
+        AlterMTMV alter = new AlterMTMV(info.getMvName(), MTMVAlterOpType.ALTER_PROPERTY);
+        alter.setMvProperties(info.getProperties());
+        this.alter.processAlterMTMV(alter, false);
+    }
+
+    public void alterMTMVStatus(TableNameInfo mvName, MTMVStatus status) {
+        AlterMTMV alter = new AlterMTMV(mvName, MTMVAlterOpType.ALTER_STATUS);
+        alter.setStatus(status);
+        this.alter.processAlterMTMV(alter, false);
+    }
+
+    public void addMTMVTaskResult(TableNameInfo mvName, MTMVTask task, MTMVRelation relation) {
+        AlterMTMV alter = new AlterMTMV(mvName, MTMVAlterOpType.ADD_TASK);
+        alter.setTask(task);
+        alter.setRelation(relation);
+        this.alter.processAlterMTMV(alter, false);
+    }
 }
diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/MTMV.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/MTMV.java
index e463c3dfe70..0c59f56db5c 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/MTMV.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/MTMV.java
@@ -17,16 +17,185 @@
 
 package org.apache.doris.catalog;
 
+import org.apache.doris.catalog.OlapTableFactory.MTMVParams;
 import org.apache.doris.common.io.Text;
+import org.apache.doris.common.util.PropertyAnalyzer;
+import org.apache.doris.job.common.TaskStatus;
+import org.apache.doris.job.extensions.mtmv.MTMVTask;
+import org.apache.doris.mtmv.EnvInfo;
+import org.apache.doris.mtmv.MTMVJobInfo;
+import org.apache.doris.mtmv.MTMVJobManager;
+import org.apache.doris.mtmv.MTMVRefreshEnum.MTMVRefreshState;
+import org.apache.doris.mtmv.MTMVRefreshEnum.MTMVState;
+import org.apache.doris.mtmv.MTMVRefreshInfo;
+import org.apache.doris.mtmv.MTMVRelation;
+import org.apache.doris.mtmv.MTMVStatus;
+import org.apache.doris.persist.gson.GsonUtils;
+
+import com.google.gson.annotations.SerializedName;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 
 import java.io.DataInput;
+import java.io.DataOutput;
 import java.io.IOException;
+import java.util.Map;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
 
 public class MTMV extends OlapTable {
+    private static final Logger LOG = LogManager.getLogger(MTMV.class);
+    private ReentrantReadWriteLock mvRwLock;
+
+    @SerializedName("ri")
+    private MTMVRefreshInfo refreshInfo;
+    @SerializedName("qs")
+    private String querySql;
+    @SerializedName("s")
+    private MTMVStatus status;
+    @SerializedName("ei")
+    private EnvInfo envInfo;
+    @SerializedName("ji")
+    private MTMVJobInfo jobInfo;
+    @SerializedName("mp")
+    private Map<String, String> mvProperties;
+    @SerializedName("r")
+    private MTMVRelation relation;
+
+    // For deserialization
+    public MTMV() {
+        type = TableType.MATERIALIZED_VIEW;
+        mvRwLock = new ReentrantReadWriteLock(true);
+    }
+
+    MTMV(MTMVParams params) {
+        super(
+                params.tableId,
+                params.tableName,
+                params.schema,
+                params.keysType,
+                params.partitionInfo,
+                params.distributionInfo
+        );
+        this.type = TableType.MATERIALIZED_VIEW;
+        this.querySql = params.querySql;
+        this.refreshInfo = params.refreshInfo;
+        this.envInfo = params.envInfo;
+        this.status = new MTMVStatus();
+        this.jobInfo = new MTMVJobInfo(MTMVJobManager.MTMV_JOB_PREFIX + params.tableId);
+        this.mvProperties = params.mvProperties;
+        mvRwLock = new ReentrantReadWriteLock(true);
+    }
+
+    public MTMVRefreshInfo getRefreshInfo() {
+        return refreshInfo;
+    }
+
+    public String getQuerySql() {
+        return querySql;
+    }
+
+    public MTMVStatus getStatus() {
+        try {
+            readMvLock();
+            return status;
+        } finally {
+            readMvUnlock();
+        }
+    }
+
+    public EnvInfo getEnvInfo() {
+        return envInfo;
+    }
+
+    public MTMVJobInfo getJobInfo() {
+        return jobInfo;
+    }
+
+    public MTMVRelation getRelation() {
+        return relation;
+    }
+
+    public MTMVRefreshInfo alterRefreshInfo(MTMVRefreshInfo newRefreshInfo) {
+        return refreshInfo.updateNotNull(newRefreshInfo);
+    }
+
+    public MTMVStatus alterStatus(MTMVStatus newStatus) {
+        try {
+            writeMvLock();
+            return this.status.updateNotNull(newStatus);
+        } finally {
+            writeMvUnlock();
+        }
+    }
+
+    public void addTaskResult(MTMVTask task, MTMVRelation relation) {
+        try {
+            writeMvLock();
+            if (task.getStatus() == TaskStatus.SUCCESS) {
+                this.status.setState(MTMVState.NORMAL);
+                this.status.setSchemaChangeDetail(null);
+                this.status.setRefreshState(MTMVRefreshState.SUCCESS);
+                this.relation = relation;
+            } else {
+                this.status.setRefreshState(MTMVRefreshState.FAIL);
+            }
+            this.jobInfo.addHistoryTask(task);
+        } finally {
+            writeMvUnlock();
+        }
+    }
+
+    public Map<String, String> alterMvProperties(Map<String, String> mvProperties) {
+        this.mvProperties.putAll(mvProperties);
+        return this.mvProperties;
+    }
+
+    public long getGracePeriod() {
+        if (mvProperties.containsKey(PropertyAnalyzer.PROPERTIES_GRACE_PERIOD)) {
+            return Long.parseLong(mvProperties.get(PropertyAnalyzer.PROPERTIES_GRACE_PERIOD));
+        } else {
+            return 0L;
+        }
+    }
+
+    public Map<String, String> getMvProperties() {
+        return mvProperties;
+    }
+
+    public void readMvLock() {
+        this.mvRwLock.readLock().lock();
+    }
+
+    public void readMvUnlock() {
+        this.mvRwLock.readLock().unlock();
+    }
+
+    public void writeMvLock() {
+        this.mvRwLock.writeLock().lock();
+    }
+
+    public void writeMvUnlock() {
+        this.mvRwLock.writeLock().unlock();
+    }
+
+    @Override
+    public void write(DataOutput out) throws IOException {
+        super.write(out);
+        Text.writeString(out, GsonUtils.GSON.toJson(this));
+    }
 
     @Override
     public void readFields(DataInput in) throws IOException {
         super.readFields(in);
-        Text.readString(in);
+        MTMV materializedView = GsonUtils.GSON.fromJson(Text.readString(in), this.getClass());
+        refreshInfo = materializedView.refreshInfo;
+        querySql = materializedView.querySql;
+        status = materializedView.status;
+        envInfo = materializedView.envInfo;
+        jobInfo = materializedView.jobInfo;
+        mvProperties = materializedView.mvProperties;
+        relation = materializedView.relation;
     }
+
 }
diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTableFactory.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTableFactory.java
index b17b58abb53..af87ec47991 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTableFactory.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/OlapTableFactory.java
@@ -17,13 +17,17 @@
 
 package org.apache.doris.catalog;
 
+import org.apache.doris.analysis.CreateMTMVStmt;
 import org.apache.doris.analysis.CreateTableStmt;
 import org.apache.doris.analysis.DdlStmt;
 import org.apache.doris.catalog.TableIf.TableType;
+import org.apache.doris.mtmv.EnvInfo;
+import org.apache.doris.mtmv.MTMVRefreshInfo;
 
 import com.google.common.base.Preconditions;
 
 import java.util.List;
+import java.util.Map;
 
 public class OlapTableFactory {
 
@@ -40,10 +44,19 @@ public class OlapTableFactory {
         public TableIndexes indexes;
     }
 
+    public static class MTMVParams extends BuildParams {
+        public MTMVRefreshInfo refreshInfo;
+        public EnvInfo envInfo;
+        public String querySql;
+        public Map<String, String> mvProperties;
+    }
+
     private BuildParams params;
 
     public static TableType getTableType(DdlStmt stmt) {
-        if (stmt instanceof CreateTableStmt) {
+        if (stmt instanceof CreateMTMVStmt) {
+            return TableType.MATERIALIZED_VIEW;
+        } else if (stmt instanceof CreateTableStmt) {
             return TableType.OLAP;
         } else {
             throw new IllegalArgumentException("Invalid DDL statement: " + stmt.toSql());
@@ -51,22 +64,28 @@ public class OlapTableFactory {
     }
 
     public OlapTableFactory init(TableType type) {
-        params = new OlapTableParams();
+        params = (type == TableType.OLAP) ? new OlapTableParams() : new MTMVParams();
         return this;
     }
 
     public Table build() {
         Preconditions.checkNotNull(params, "The factory isn't initialized.");
-        OlapTableParams olapTableParams = (OlapTableParams) params;
-        return new OlapTable(
-                olapTableParams.tableId,
-                olapTableParams.tableName,
-                olapTableParams.schema,
-                olapTableParams.keysType,
-                olapTableParams.partitionInfo,
-                olapTableParams.distributionInfo,
-                olapTableParams.indexes
-        );
+
+        if (params instanceof OlapTableParams) {
+            OlapTableParams olapTableParams = (OlapTableParams) params;
+            return new OlapTable(
+                    olapTableParams.tableId,
+                    olapTableParams.tableName,
+                    olapTableParams.schema,
+                    olapTableParams.keysType,
+                    olapTableParams.partitionInfo,
+                    olapTableParams.distributionInfo,
+                    olapTableParams.indexes
+            );
+        } else {
+            MTMVParams mtmvParams = (MTMVParams) params;
+            return new MTMV(mtmvParams);
+        }
     }
 
     public OlapTableFactory withTableId(long tableId) {
@@ -107,8 +126,49 @@ public class OlapTableFactory {
         return this;
     }
 
+    public OlapTableFactory withQuerySql(String querySql) {
+        Preconditions.checkState(params instanceof MTMVParams, "Invalid argument for "
+                + params.getClass().getSimpleName());
+        MTMVParams mtmvParams = (MTMVParams) params;
+        mtmvParams.querySql = querySql;
+        return this;
+    }
+
+    public OlapTableFactory withMvProperties(Map<String, String> mvProperties) {
+        Preconditions.checkState(params instanceof MTMVParams, "Invalid argument for "
+                + params.getClass().getSimpleName());
+        MTMVParams mtmvParams = (MTMVParams) params;
+        mtmvParams.mvProperties = mvProperties;
+        return this;
+    }
+
+    private OlapTableFactory withRefreshInfo(MTMVRefreshInfo refreshInfo) {
+        Preconditions.checkState(params instanceof MTMVParams, "Invalid argument for "
+                + params.getClass().getSimpleName());
+        MTMVParams mtmvParams = (MTMVParams) params;
+        mtmvParams.refreshInfo = refreshInfo;
+        return this;
+    }
+
+    private OlapTableFactory withEnvInfo(EnvInfo envInfo) {
+        Preconditions.checkState(params instanceof MTMVParams, "Invalid argument for "
+                + params.getClass().getSimpleName());
+        MTMVParams mtmvParams = (MTMVParams) params;
+        mtmvParams.envInfo = envInfo;
+        return this;
+    }
+
     public OlapTableFactory withExtraParams(DdlStmt stmt) {
-        CreateTableStmt createOlapTableStmt = (CreateTableStmt) stmt;
-        return withIndexes(new TableIndexes(createOlapTableStmt.getIndexes()));
+        boolean isMaterializedView = stmt instanceof CreateMTMVStmt;
+        if (!isMaterializedView) {
+            CreateTableStmt createOlapTableStmt = (CreateTableStmt) stmt;
+            return withIndexes(new TableIndexes(createOlapTableStmt.getIndexes()));
+        } else {
+            CreateMTMVStmt createMTMVStmt = (CreateMTMVStmt) stmt;
+            return withRefreshInfo(createMTMVStmt.getRefreshInfo())
+                    .withQuerySql(createMTMVStmt.getQuerySql())
+                    .withMvProperties(createMTMVStmt.getMvProperties())
+                    .withEnvInfo(createMTMVStmt.getEnvInfo());
+        }
     }
 }
diff --git a/fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java b/fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java
index 46e1ad04c2b..6fb93756f65 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/common/util/PropertyAnalyzer.java
@@ -157,6 +157,7 @@ public class PropertyAnalyzer {
 
     public static final String PROPERTIES_ENABLE_DUPLICATE_WITHOUT_KEYS_BY_DEFAULT =
             "enable_duplicate_without_keys_by_default";
+    public static final String PROPERTIES_GRACE_PERIOD = "grace_period";
     // For unique key data model, the feature Merge-on-Write will leverage a primary
     // key index and a delete-bitmap to mark duplicate keys as deleted in load stage,
     // which can avoid the merging cost in read stage, and accelerate the aggregation
diff --git a/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java b/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java
index a8f548185c9..8706b36d012 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java
@@ -75,6 +75,7 @@ import org.apache.doris.catalog.InfoSchemaDb;
 import org.apache.doris.catalog.JdbcTable;
 import org.apache.doris.catalog.KeysType;
 import org.apache.doris.catalog.ListPartitionItem;
+import org.apache.doris.catalog.MTMV;
 import org.apache.doris.catalog.MaterializedIndex;
 import org.apache.doris.catalog.MaterializedIndex.IndexExtState;
 import org.apache.doris.catalog.MaterializedIndex.IndexState;
@@ -882,6 +883,12 @@ public class InternalCatalog implements CatalogIf<Database> {
                 }
             }
 
+            if (!stmt.isMaterializedView() && table instanceof MTMV) {
+                ErrorReport.reportDdlException(ErrorCode.ERR_WRONG_OBJECT, dbName, tableName, "TABLE");
+            } else if (stmt.isMaterializedView() && !(table instanceof MTMV)) {
+                ErrorReport.reportDdlException(ErrorCode.ERR_WRONG_OBJECT, dbName, tableName, "MTMV");
+            }
+
             if (!stmt.isForceDrop()) {
                 if (Env.getCurrentGlobalTransactionMgr().existCommittedTxns(db.getId(), table.getId(), null)) {
                     throw new DdlException(
@@ -915,6 +922,12 @@ public class InternalCatalog implements CatalogIf<Database> {
             Env.getCurrentEnv().getQueryStats().clear(Env.getCurrentEnv().getCurrentCatalog().getId(),
                     db.getId(), table.getId());
             Env.getCurrentEnv().getAnalysisManager().removeTableStats(table.getId());
+            if (table.getType() == TableType.MATERIALIZED_VIEW) {
+                Env.getCurrentEnv().getMtmvService().dropMTMV((MTMV) table);
+            }
+            Env.getCurrentEnv().getMtmvService().dropTable(table);
+        } catch (UserException e) {
+            throw new DdlException(e.getMessage(), e);
         } finally {
             db.writeUnlock();
         }
@@ -932,6 +945,8 @@ public class InternalCatalog implements CatalogIf<Database> {
         } else if (table.getType() == TableType.ICEBERG) {
             // drop Iceberg database table creation record
             icebergTableCreationRecordMgr.deregisterTable(db, (IcebergTable) table);
+        } else if (table.getType() == TableType.MATERIALIZED_VIEW) {
+            Env.getCurrentEnv().getMtmvService().deregisterMTMV((MTMV) table);
         }
 
         db.dropTable(table.getName());
@@ -1318,7 +1333,7 @@ public class InternalCatalog implements CatalogIf<Database> {
         try {
             Table table = db.getTableOrDdlException(tableName);
 
-            if (table.getType() != TableType.OLAP) {
+            if (table.getType() != TableType.OLAP && table.getType() != TableType.MATERIALIZED_VIEW) {
                 throw new DdlException("Only support create partition from a OLAP table");
             }
 
@@ -1661,7 +1676,8 @@ public class InternalCatalog implements CatalogIf<Database> {
 
     public void replayAddPartition(PartitionPersistInfo info) throws MetaNotFoundException {
         Database db = (Database) getDbOrMetaException(info.getDbId());
-        OlapTable olapTable = (OlapTable) db.getTableOrMetaException(info.getTableId(), TableType.OLAP);
+        OlapTable olapTable = (OlapTable) db.getTableOrMetaException(info.getTableId(),
+                Lists.newArrayList(TableType.OLAP, TableType.MATERIALIZED_VIEW));
         olapTable.writeLock();
         try {
             Partition partition = info.getPartition();
@@ -2597,6 +2613,9 @@ public class InternalCatalog implements CatalogIf<Database> {
 
             throw e;
         }
+        if (olapTable instanceof MTMV) {
+            Env.getCurrentEnv().getMtmvService().createMTMV((MTMV) olapTable);
+        }
     }
 
     private void createMysqlTable(Database db, CreateTableStmt stmt) throws DdlException {
diff --git a/fe/fe-core/src/main/java/org/apache/doris/job/base/AbstractJob.java b/fe/fe-core/src/main/java/org/apache/doris/job/base/AbstractJob.java
index 6e2498cf013..908676df5ba 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/job/base/AbstractJob.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/job/base/AbstractJob.java
@@ -18,25 +18,29 @@
 package org.apache.doris.job.base;
 
 import org.apache.doris.analysis.UserIdentity;
+import org.apache.doris.catalog.Column;
 import org.apache.doris.catalog.Env;
+import org.apache.doris.catalog.ScalarType;
 import org.apache.doris.common.io.Text;
 import org.apache.doris.common.io.Writable;
 import org.apache.doris.common.util.TimeUtils;
 import org.apache.doris.job.common.JobStatus;
-import org.apache.doris.job.common.JobType;
 import org.apache.doris.job.common.TaskStatus;
 import org.apache.doris.job.exception.JobException;
-import org.apache.doris.job.extensions.insert.InsertJob;
 import org.apache.doris.job.task.AbstractTask;
-import org.apache.doris.job.task.Task;
+import org.apache.doris.persist.gson.GsonUtils;
+import org.apache.doris.qe.ShowResultSetMetaData;
 
+import com.google.common.collect.ImmutableList;
 import com.google.gson.annotations.SerializedName;
 import lombok.Data;
 import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.RandomUtils;
 
 import java.io.DataInput;
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.List;
 
 @Data
@@ -72,16 +76,30 @@ public abstract class AbstractJob<T extends AbstractTask> implements Job<T>, Wri
     private List<T> runningTasks = new ArrayList<>();
 
     @Override
-    public void cancel() throws JobException {
+    public void cancelAllTasks() throws JobException {
         if (CollectionUtils.isEmpty(runningTasks)) {
             return;
         }
-        runningTasks.forEach(Task::cancel);
-
+        for (T task : runningTasks) {
+            task.cancel();
+        }
     }
 
+    private static final ImmutableList<String> TITLE_NAMES =
+            new ImmutableList.Builder<String>()
+                    .add("Id")
+                    .add("Name")
+                    .add("Definer")
+                    .add("ExecuteType")
+                    .add("RecurringStrategy")
+                    .add("Status")
+                    .add("ExecuteSql")
+                    .add("CreateTime")
+                    .add("Comment")
+                    .build();
+
     @Override
-    public void cancel(long taskId) throws JobException {
+    public void cancelTaskById(long taskId) throws JobException {
         if (CollectionUtils.isEmpty(runningTasks)) {
             throw new JobException("no running task");
         }
@@ -89,13 +107,17 @@ public abstract class AbstractJob<T extends AbstractTask> implements Job<T>, Wri
                 .orElseThrow(() -> new JobException("no task id:" + taskId)).cancel();
     }
 
-    public void initTasks(List<T> tasks) {
+    public void initTasks(List<? extends AbstractTask> tasks) {
         tasks.forEach(task -> {
             task.setJobId(jobId);
-            task.setTaskId(Env.getCurrentEnv().getNextId());
+            task.setTaskId(getNextId());
             task.setCreateTimeMs(System.currentTimeMillis());
             task.setStatus(TaskStatus.PENDING);
         });
+        if (CollectionUtils.isEmpty(getRunningTasks())) {
+            setRunningTasks(new ArrayList<>());
+        }
+        getRunningTasks().addAll((Collection<? extends T>) tasks);
     }
 
     public void checkJobParams() {
@@ -105,7 +127,7 @@ public abstract class AbstractJob<T extends AbstractTask> implements Job<T>, Wri
         if (null == jobConfig) {
             throw new IllegalArgumentException("jobConfig cannot be null");
         }
-        jobConfig.checkParams(createTimeMs);
+        jobConfig.checkParams();
         checkJobParamsInternal();
     }
 
@@ -132,23 +154,16 @@ public abstract class AbstractJob<T extends AbstractTask> implements Job<T>, Wri
     protected abstract void checkJobParamsInternal();
 
     public static AbstractJob readFields(DataInput in) throws IOException {
-        // todo use RuntimeTypeAdapterFactory of Gson to do the serde
-        JobType jobType = JobType.valueOf(Text.readString(in));
-        switch (jobType) {
-            case INSERT:
-                return InsertJob.readFields(in);
-            case MTMV:
-                // return MTMVJob.readFields(in);
-                break;
-            default:
-                throw new IllegalArgumentException("unknown job type");
-        }
-        throw new IllegalArgumentException("unknown job type");
+        String jsonJob = Text.readString(in);
+        AbstractJob<?> job = GsonUtils.GSON.fromJson(jsonJob, AbstractJob.class);
+        job.setRunningTasks(new ArrayList<>());
+        return job;
     }
 
     @Override
     public void onTaskFail(T task) {
         updateJobStatusIfEnd();
+        runningTasks.remove(task);
     }
 
     @Override
@@ -166,16 +181,14 @@ public abstract class AbstractJob<T extends AbstractTask> implements Job<T>, Wri
         switch (executeType) {
             case ONE_TIME:
             case INSTANT:
-                jobStatus = JobStatus.FINISHED;
-                Env.getCurrentEnv().getJobManager().getJob(jobId).updateJobStatus(jobStatus);
+                Env.getCurrentEnv().getJobManager().getJob(jobId).updateJobStatus(JobStatus.FINISHED);
                 break;
             case RECURRING:
                 TimerDefinition timerDefinition = getJobConfig().getTimerDefinition();
                 if (null != timerDefinition.getEndTimeMs()
                         && timerDefinition.getEndTimeMs() < System.currentTimeMillis()
                         + timerDefinition.getIntervalUnit().getIntervalMs(timerDefinition.getInterval())) {
-                    jobStatus = JobStatus.FINISHED;
-                    Env.getCurrentEnv().getJobManager().getJob(jobId).updateJobStatus(jobStatus);
+                    Env.getCurrentEnv().getJobManager().getJob(jobId).updateJobStatus(JobStatus.FINISHED);
                 }
                 break;
             default:
@@ -202,4 +215,23 @@ public abstract class AbstractJob<T extends AbstractTask> implements Job<T>, Wri
         commonShowInfo.add(comment);
         return commonShowInfo;
     }
+
+    @Override
+    public List<String> getShowInfo() {
+        return getCommonShowInfo();
+    }
+
+    @Override
+    public ShowResultSetMetaData getJobMetaData() {
+        ShowResultSetMetaData.Builder builder = ShowResultSetMetaData.builder();
+
+        for (String title : TITLE_NAMES) {
+            builder.addColumn(new Column(title, ScalarType.createVarchar(30)));
+        }
+        return builder.build();
+    }
+
+    private static long getNextId() {
+        return System.nanoTime() + RandomUtils.nextInt();
+    }
 }
diff --git a/fe/fe-core/src/main/java/org/apache/doris/job/base/Job.java b/fe/fe-core/src/main/java/org/apache/doris/job/base/Job.java
index 25e93928d82..fef447d160f 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/job/base/Job.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/job/base/Job.java
@@ -50,7 +50,7 @@ public interface Job<T extends AbstractTask> {
      * @throws JobException If the task is not in the running state, it may have already
      * finished and cannot be cancelled.
      */
-    void cancel(long taskId) throws JobException;
+    void cancelTaskById(long taskId) throws JobException;
 
     /**
      * Checks if the job is ready for scheduling.
@@ -95,7 +95,7 @@ public interface Job<T extends AbstractTask> {
      *
      * @throws JobException If cancelling a running task fails.
      */
-    void cancel() throws JobException;
+    void cancelAllTasks() throws JobException;
 
     /**
      * Notifies the job when a task execution fails.
@@ -112,9 +112,8 @@ public interface Job<T extends AbstractTask> {
     void onTaskSuccess(T task);
 
     /**
-     * Notifies the job when a task execution is cancelled.
-     *
-     * @param task The cancelled task.
+     * get the job's show info, which is used to sql show the job information
+     * @return List<String> job common show info
      */
-    void onTaskCancel(T task);
+    List<String> getShowInfo();
 }
diff --git a/fe/fe-core/src/main/java/org/apache/doris/job/base/JobExecutionConfiguration.java b/fe/fe-core/src/main/java/org/apache/doris/job/base/JobExecutionConfiguration.java
index ead943d4bf1..16b9dd24281 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/job/base/JobExecutionConfiguration.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/job/base/JobExecutionConfiguration.java
@@ -38,15 +38,18 @@ public class JobExecutionConfiguration {
     @SerializedName(value = "ec")
     private JobExecuteType executeType;
 
+    @Getter
+    @Setter
+    private boolean immediate = false;
+
     /**
      * Maximum number of concurrent tasks, <= 0 means no limit
      * if the number of tasks exceeds the limit, the task will be delayed execution
      * todo: implement this later, we need to consider concurrency strategies
      */
-    @SerializedName(value = "maxConcurrentTaskNum")
     private Integer maxConcurrentTaskNum;
 
-    public void checkParams(Long createTimeMs) {
+    public void checkParams() {
         if (executeType == null) {
             throw new IllegalArgumentException("executeType cannot be null");
         }
@@ -55,7 +58,7 @@ public class JobExecutionConfiguration {
             return;
         }
 
-        checkTimerDefinition(createTimeMs);
+        checkTimerDefinition(immediate);
 
         if (executeType == JobExecuteType.ONE_TIME) {
             validateStartTimeMs();
@@ -77,12 +80,12 @@ public class JobExecutionConfiguration {
         }
     }
 
-    private void checkTimerDefinition(long createTimeMs) {
+    private void checkTimerDefinition(boolean immediate) {
         if (timerDefinition == null) {
             throw new IllegalArgumentException(
                     "timerDefinition cannot be null when executeType is not instant or manual");
         }
-        timerDefinition.checkParams(createTimeMs);
+        timerDefinition.checkParams(immediate);
     }
 
     private void validateStartTimeMs() {
@@ -130,9 +133,14 @@ public class JobExecutionConfiguration {
                     && timerDefinition.getEndTimeMs() < startTimeMs) {
                 return delayTimeSeconds;
             }
+            long intervalValue = timerDefinition.getIntervalUnit().getIntervalMs(timerDefinition.getInterval());
+            long jobStartTimeMs = timerDefinition.getStartTimeMs();
+            if (isImmediate()) {
+                jobStartTimeMs += intervalValue;
+            }
 
-            return getExecutionDelaySeconds(startTimeMs, endTimeMs, timerDefinition.getStartTimeMs(),
-                    timerDefinition.getIntervalUnit().getIntervalMs(timerDefinition.getInterval()), currentTimeMs);
+            return getExecutionDelaySeconds(startTimeMs, endTimeMs, jobStartTimeMs,
+                    intervalValue, currentTimeMs);
         }
 
         return delayTimeSeconds;
@@ -160,7 +168,6 @@ public class JobExecutionConfiguration {
 
         long firstTriggerTime = windowStartTimeMs + (intervalMs - ((windowStartTimeMs - startTimeMs)
                 % intervalMs)) % intervalMs;
-
         if (firstTriggerTime < currentTimeMs) {
             firstTriggerTime += intervalMs;
         }
@@ -173,6 +180,7 @@ public class JobExecutionConfiguration {
         for (long triggerTime = firstTriggerTime; triggerTime <= windowEndTimeMs; triggerTime += intervalMs) {
             if (triggerTime >= currentTimeMs && (null == timerDefinition.getEndTimeMs()
                     || triggerTime < timerDefinition.getEndTimeMs())) {
+                timerDefinition.setLatestSchedulerTimeMs(triggerTime);
                 timestamps.add(queryDelayTimeSecond(currentTimeMs, triggerTime));
             }
         }
diff --git a/fe/fe-core/src/main/java/org/apache/doris/job/base/TimerDefinition.java b/fe/fe-core/src/main/java/org/apache/doris/job/base/TimerDefinition.java
index 153bc2c43c7..978538e607d 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/job/base/TimerDefinition.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/job/base/TimerDefinition.java
@@ -38,12 +38,18 @@ public class TimerDefinition {
     private Long latestSchedulerTimeMs;
 
 
-    public void checkParams(Long createTimeMs) {
+    public void checkParams(boolean immediate) {
         if (null != startTimeMs && startTimeMs < System.currentTimeMillis()) {
             throw new IllegalArgumentException("startTimeMs must be greater than current time");
         }
+        if (null != startTimeMs && immediate) {
+            throw new IllegalArgumentException("startTimeMs must be null when immediate is true");
+        }
+        if (null == startTimeMs && immediate) {
+            startTimeMs = System.currentTimeMillis();
+        }
         if (null == startTimeMs) {
-            startTimeMs = createTimeMs + intervalUnit.getIntervalMs(interval);
+            startTimeMs = System.currentTimeMillis() + intervalUnit.getIntervalMs(interval);
         }
         if (null != endTimeMs && endTimeMs < startTimeMs) {
             throw new IllegalArgumentException("end time cannot be less than start time");
diff --git a/fe/fe-core/src/main/java/org/apache/doris/job/extensions/insert/InsertJob.java b/fe/fe-core/src/main/java/org/apache/doris/job/extensions/insert/InsertJob.java
index 70a558009db..eb5e9499e38 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/job/extensions/insert/InsertJob.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/job/extensions/insert/InsertJob.java
@@ -17,53 +17,93 @@
 
 package org.apache.doris.job.extensions.insert;
 
+import org.apache.doris.catalog.Column;
 import org.apache.doris.catalog.Env;
+import org.apache.doris.catalog.ScalarType;
+import org.apache.doris.common.MetaNotFoundException;
 import org.apache.doris.common.io.Text;
 import org.apache.doris.job.base.AbstractJob;
+import org.apache.doris.job.base.JobExecuteType;
 import org.apache.doris.job.common.JobType;
 import org.apache.doris.job.common.TaskType;
 import org.apache.doris.job.exception.JobException;
+import org.apache.doris.load.loadv2.LoadJob;
+import org.apache.doris.nereids.trees.plans.commands.InsertIntoTableCommand;
 import org.apache.doris.persist.gson.GsonUtils;
+import org.apache.doris.qe.ConnectContext;
 import org.apache.doris.qe.ShowResultSetMetaData;
+import org.apache.doris.qe.StmtExecutor;
 
 import com.google.gson.annotations.SerializedName;
 import lombok.Data;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
 
-import java.io.DataInput;
 import java.io.DataOutput;
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
+import java.util.concurrent.ConcurrentLinkedQueue;
 
 @Data
+@Slf4j
 public class InsertJob extends AbstractJob<InsertTask> {
 
-    @SerializedName(value = "labelPrefix")
+    @SerializedName(value = "lp")
     String labelPrefix;
 
+    InsertIntoTableCommand command;
+
+    StmtExecutor stmtExecutor;
+
+    ConnectContext ctx;
+
+    @SerializedName("tis")
+    ConcurrentLinkedQueue<Long> taskIdList;
+
+    // max save task num, do we need to config it?
+    private static final int MAX_SAVE_TASK_NUM = 50;
+
 
     @Override
     public List<InsertTask> createTasks(TaskType taskType) {
-        InsertTask task = new InsertTask(null, null, null, null, null);
+        InsertTask task = new InsertTask(null, getCurrentDbName(), getExecuteSql(), getCreateUser());
         task.setJobId(getJobId());
         task.setTaskType(taskType);
         task.setTaskId(Env.getCurrentEnv().getNextId());
         ArrayList<InsertTask> tasks = new ArrayList<>();
         tasks.add(task);
         super.initTasks(tasks);
-        getRunningTasks().addAll(tasks);
+        addNewTask(task.getTaskId());
         return tasks;
     }
 
+    public void addNewTask(long id) {
+
+        if (CollectionUtils.isEmpty(taskIdList)) {
+            taskIdList = new ConcurrentLinkedQueue<>();
+            Env.getCurrentEnv().getEditLog().logUpdateJob(this);
+            taskIdList.add(id);
+            return;
+        }
+        taskIdList.add(id);
+        if (taskIdList.size() >= MAX_SAVE_TASK_NUM) {
+            taskIdList.poll();
+        }
+        Env.getCurrentEnv().getEditLog().logUpdateJob(this);
+    }
+
     @Override
-    public void cancel(long taskId) throws JobException {
-        super.cancel();
+    public void cancelTaskById(long taskId) throws JobException {
+        super.cancelTaskById(taskId);
     }
 
 
     @Override
-    public void cancel() throws JobException {
-        super.cancel();
+    public void cancelAllTasks() throws JobException {
+        super.cancelAllTasks();
     }
 
     @Override
@@ -74,16 +114,41 @@ public class InsertJob extends AbstractJob<InsertTask> {
 
     @Override
     protected void checkJobParamsInternal() {
-
-    }
-
-    public static InsertJob readFields(DataInput in) throws IOException {
-        return GsonUtils.GSON.fromJson(Text.readString(in), InsertJob.class);
+        if (command == null && StringUtils.isBlank(getExecuteSql())) {
+            throw new IllegalArgumentException("command or sql is null,must be set");
+        }
+        if (null != command && !getJobConfig().getExecuteType().equals(JobExecuteType.INSTANT)) {
+            throw new IllegalArgumentException("command must be null when executeType is not instant");
+        }
     }
 
     @Override
     public List<InsertTask> queryTasks() {
-        return null;
+        if (CollectionUtils.isEmpty(taskIdList)) {
+            return new ArrayList<>();
+        }
+        //TODO it's will be refactor, we will storage task info in job inner and query from it
+        List<Long> taskIdList = new ArrayList<>(this.taskIdList);
+        Collections.reverse(taskIdList);
+        List<LoadJob> loadJobs = Env.getCurrentEnv().getLoadManager().queryLoadJobsByJobIds(taskIdList);
+        if (CollectionUtils.isEmpty(loadJobs)) {
+            return new ArrayList<>();
+        }
+        List<InsertTask> tasks = new ArrayList<>();
+        loadJobs.forEach(loadJob -> {
+            InsertTask task;
+            try {
+                task = new InsertTask(loadJob.getLabel(), loadJob.getDb().getFullName(), null, getCreateUser());
+            } catch (MetaNotFoundException e) {
+                log.warn("load job not found,job id is {}", loadJob.getId());
+                return;
+            }
+            task.setJobId(getJobId());
+            task.setTaskId(loadJob.getId());
+            task.setLoadJob(loadJob);
+            tasks.add(task);
+        });
+        return tasks;
     }
 
     @Override
@@ -93,12 +158,12 @@ public class InsertJob extends AbstractJob<InsertTask> {
 
     @Override
     public ShowResultSetMetaData getJobMetaData() {
-        return null;
+        return super.getJobMetaData();
     }
 
     @Override
     public ShowResultSetMetaData getTaskMetaData() {
-        return null;
+        return TASK_META_DATA;
     }
 
     @Override
@@ -108,18 +173,32 @@ public class InsertJob extends AbstractJob<InsertTask> {
 
     @Override
     public void onTaskSuccess(InsertTask task) {
-        getRunningTasks().remove(task);
+        super.onTaskSuccess(task);
     }
 
     @Override
-    public void onTaskCancel(InsertTask task) {
-        getRunningTasks().remove(task);
+    public List<String> getShowInfo() {
+        return super.getCommonShowInfo();
     }
 
-
     @Override
     public void write(DataOutput out) throws IOException {
-        Text.writeString(out, JobType.INSERT.name());
         Text.writeString(out, GsonUtils.GSON.toJson(this));
     }
+
+    private static final ShowResultSetMetaData TASK_META_DATA =
+            ShowResultSetMetaData.builder()
+                    .addColumn(new Column("TaskId", ScalarType.createVarchar(20)))
+                    .addColumn(new Column("Label", ScalarType.createVarchar(20)))
+                    .addColumn(new Column("Status", ScalarType.createVarchar(20)))
+                    .addColumn(new Column("EtlInfo", ScalarType.createVarchar(20)))
+                    .addColumn(new Column("TaskInfo", ScalarType.createVarchar(20)))
+                    .addColumn(new Column("ErrorMsg", ScalarType.createVarchar(20)))
+
+                    .addColumn(new Column("CreateTimeMs", ScalarType.createVarchar(20)))
+                    .addColumn(new Column("FinishTimeMs", ScalarType.createVarchar(20)))
+                    .addColumn(new Column("TrackingUrl", ScalarType.createVarchar(20)))
+                    .addColumn(new Column("LoadStatistic", ScalarType.createVarchar(20)))
+                    .addColumn(new Column("User", ScalarType.createVarchar(20)))
+                    .build();
 }
diff --git a/fe/fe-core/src/main/java/org/apache/doris/job/extensions/insert/InsertTask.java b/fe/fe-core/src/main/java/org/apache/doris/job/extensions/insert/InsertTask.java
index 9802ebc55d0..38b3969d7d8 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/job/extensions/insert/InsertTask.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/job/extensions/insert/InsertTask.java
@@ -17,14 +17,32 @@
 
 package org.apache.doris.job.extensions.insert;
 
+import org.apache.doris.analysis.UserIdentity;
+import org.apache.doris.catalog.Env;
+import org.apache.doris.common.FeConstants;
 import org.apache.doris.common.util.TimeUtils;
+import org.apache.doris.job.exception.JobException;
 import org.apache.doris.job.task.AbstractTask;
-import org.apache.doris.load.FailMsg;
 import org.apache.doris.load.loadv2.LoadJob;
+import org.apache.doris.nereids.parser.NereidsParser;
 import org.apache.doris.nereids.trees.plans.commands.InsertIntoTableCommand;
+import org.apache.doris.qe.ConnectContext;
+import org.apache.doris.qe.StmtExecutor;
+import org.apache.doris.system.SystemInfoService;
+import org.apache.doris.thrift.TUniqueId;
 
+import com.google.common.base.Joiner;
+import com.google.common.collect.Lists;
+import lombok.Getter;
+import lombok.Setter;
 import lombok.extern.slf4j.Slf4j;
 
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.concurrent.atomic.AtomicBoolean;
+
 /**
  * todo implement this later
  */
@@ -34,44 +52,140 @@ public class InsertTask extends AbstractTask {
     private String labelName;
 
     private InsertIntoTableCommand command;
-    private LoadJob.LoadStatistic statistic;
-    private FailMsg failMsg;
 
-    private InsertIntoState insertIntoState;
+    private StmtExecutor stmtExecutor;
+
+    private ConnectContext ctx;
+
+    private String sql;
+
+    private String currentDb;
+
+    private UserIdentity userIdentity;
+
+    private AtomicBoolean isCanceled = new AtomicBoolean(false);
+
+    private AtomicBoolean isFinished = new AtomicBoolean(false);
+
+
+    @Getter
+    @Setter
+    private LoadJob loadJob;
+
 
     @Override
-    public void before() {
+    public void before() throws JobException {
+        if (isCanceled.get()) {
+            throw new JobException("Export executor has been canceled, task id: {}", getTaskId());
+        }
+        ctx = new ConnectContext();
+        ctx.setEnv(Env.getCurrentEnv());
+        ctx.setCluster(SystemInfoService.DEFAULT_CLUSTER);
+        ctx.setQualifiedUser(userIdentity.getQualifiedUser());
+        ctx.setCurrentUserIdentity(userIdentity);
+        ctx.getState().reset();
+        ctx.setThreadLocalInfo();
+        ctx.setDatabase(currentDb);
+        TUniqueId queryId = generateQueryId(UUID.randomUUID().toString());
+        ctx.getSessionVariable().enableFallbackToOriginalPlanner = false;
+        stmtExecutor = new StmtExecutor(ctx, (String) null);
+        ctx.setQueryId(queryId);
+        NereidsParser parser = new NereidsParser();
+        this.command = (InsertIntoTableCommand) parser.parseSingle(sql);
+        this.command.setLabelName(Optional.of(getJobId() + "_" + getTaskId()));
+        this.command.setJobId(getTaskId());
+
         super.before();
+
+    }
+
+    protected TUniqueId generateQueryId(String taskIdString) {
+        UUID taskId = UUID.fromString(taskIdString);
+        return new TUniqueId(taskId.getMostSignificantBits(), taskId.getLeastSignificantBits());
     }
 
-    public InsertTask(String labelName, InsertIntoTableCommand command, LoadJob.LoadStatistic statistic,
-                      FailMsg failMsg, InsertIntoState insertIntoState) {
+    public InsertTask(String labelName, String currentDb, String sql, UserIdentity userIdentity) {
         this.labelName = labelName;
-        this.command = command;
-        this.statistic = statistic;
-        this.failMsg = failMsg;
-        this.insertIntoState = insertIntoState;
+        this.sql = sql;
+        this.currentDb = currentDb;
+        this.userIdentity = userIdentity;
+
     }
 
     @Override
-    public void run() {
-        //just for test
-        log.info(getJobId() + "InsertTask run" + TimeUtils.longToTimeString(System.currentTimeMillis()));
+    public void run() throws JobException {
+        try {
+            command.run(ctx, stmtExecutor);
+        } catch (Exception e) {
+            throw new JobException(e);
+        }
     }
 
     @Override
-    public void onFail() {
+    public void onFail() throws JobException {
+        isFinished.set(true);
         super.onFail();
     }
 
     @Override
-    public void onSuccess() {
+    public void onSuccess() throws JobException {
+        isFinished.set(true);
         super.onSuccess();
     }
 
     @Override
-    public void cancel() {
+    public void cancel() throws JobException {
+        if (isFinished.get() || isCanceled.get()) {
+            return;
+        }
+        isCanceled.getAndSet(true);
+        if (null != stmtExecutor) {
+            stmtExecutor.cancel();
+        }
         super.cancel();
     }
 
+    @Override
+    public List<String> getShowInfo() {
+        if (null == loadJob) {
+            return new ArrayList<>();
+        }
+        List<String> jobInfo = Lists.newArrayList();
+        // jobId
+        jobInfo.add(String.valueOf(loadJob.getId()));
+        // label
+        jobInfo.add(loadJob.getLabel());
+        // state
+        jobInfo.add(loadJob.getState().name());
+
+        // etl info
+        if (loadJob.getLoadingStatus().getCounters().isEmpty()) {
+            jobInfo.add(FeConstants.null_string);
+        } else {
+            jobInfo.add(Joiner.on("; ").withKeyValueSeparator("=").join(loadJob.getLoadingStatus().getCounters()));
+        }
+
+        // task info
+        jobInfo.add("cluster:" + loadJob.getResourceName() + "; timeout(s):" + loadJob.getTimeout()
+                + "; max_filter_ratio:" + loadJob.getMaxFilterRatio() + "; priority:" + loadJob.getPriority());
+        // error msg
+        if (loadJob.getFailMsg() == null) {
+            jobInfo.add(FeConstants.null_string);
+        } else {
+            jobInfo.add("type:" + loadJob.getFailMsg().getCancelType() + "; msg:" + loadJob.getFailMsg().getMsg());
+        }
+
+        // create time
+        jobInfo.add(TimeUtils.longToTimeString(loadJob.getCreateTimestamp()));
+
+        // load end time
+        jobInfo.add(TimeUtils.longToTimeString(loadJob.getFinishTimestamp()));
+        // tracking url
+        jobInfo.add(loadJob.getLoadingStatus().getTrackingUrl());
+        jobInfo.add(loadJob.getLoadStatistic().toJson());
+        // user
+        jobInfo.add(loadJob.getUserInfo().getQualifiedUser());
+        return jobInfo;
+    }
+
 }
diff --git a/fe/fe-core/src/main/java/org/apache/doris/job/extensions/mtmv/MTMVJob.java b/fe/fe-core/src/main/java/org/apache/doris/job/extensions/mtmv/MTMVJob.java
new file mode 100644
index 00000000000..c08a96ee6eb
--- /dev/null
+++ b/fe/fe-core/src/main/java/org/apache/doris/job/extensions/mtmv/MTMVJob.java
@@ -0,0 +1,152 @@
+// 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.
+
+package org.apache.doris.job.extensions.mtmv;
+
+import org.apache.doris.catalog.Column;
+import org.apache.doris.catalog.Database;
+import org.apache.doris.catalog.Env;
+import org.apache.doris.catalog.MTMV;
+import org.apache.doris.catalog.ScalarType;
+import org.apache.doris.catalog.TableIf.TableType;
+import org.apache.doris.common.DdlException;
+import org.apache.doris.common.MetaNotFoundException;
+import org.apache.doris.common.io.Text;
+import org.apache.doris.common.util.TimeUtils;
+import org.apache.doris.job.base.AbstractJob;
+import org.apache.doris.job.common.JobType;
+import org.apache.doris.job.common.TaskType;
+import org.apache.doris.persist.gson.GsonUtils;
+import org.apache.doris.qe.ShowResultSetMetaData;
+
+import com.google.common.collect.Lists;
+import com.google.gson.annotations.SerializedName;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import java.io.DataOutput;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+public class MTMVJob extends AbstractJob<MTMVTask> {
+    private static final Logger LOG = LogManager.getLogger(MTMVJob.class);
+    private static final ShowResultSetMetaData JOB_META_DATA =
+            ShowResultSetMetaData.builder()
+                    .addColumn(new Column("JobId", ScalarType.createVarchar(20)))
+                    .addColumn(new Column("JobName", ScalarType.createVarchar(20)))
+                    .addColumn(new Column("ExecuteType", ScalarType.createVarchar(20)))
+                    .addColumn(new Column("RecurringStrategy", ScalarType.createVarchar(20)))
+                    .addColumn(new Column("JobStatus", ScalarType.createVarchar(20)))
+                    .addColumn(new Column("CreateTime", ScalarType.createVarchar(20)))
+                    .addColumn(new Column("Comment", ScalarType.createVarchar(20)))
+                    .build();
+    private static final ShowResultSetMetaData TASK_META_DATA =
+            ShowResultSetMetaData.builder()
+                    .addColumn(new Column("JobId", ScalarType.createVarchar(20)))
+                    .addColumn(new Column("TaskId", ScalarType.createVarchar(20)))
+                    .addColumn(new Column("Status", ScalarType.createVarchar(20)))
+                    .addColumn(new Column("CreateTime", ScalarType.createVarchar(20)))
+                    .addColumn(new Column("StartTime", ScalarType.createVarchar(20)))
+                    .addColumn(new Column("FinishTime", ScalarType.createVarchar(20)))
+                    .addColumn(new Column("DurationMs", ScalarType.createVarchar(20)))
+                    .addColumn(new Column("ExecuteSql", ScalarType.createVarchar(20)))
+                    .build();
+
+    @SerializedName(value = "di")
+    private long dbId;
+    @SerializedName(value = "mi")
+    private long mtmvId;
+
+    public MTMVJob(long dbId, long mtmvId) {
+        this.dbId = dbId;
+        this.mtmvId = mtmvId;
+        super.setCreateTimeMs(System.currentTimeMillis());
+    }
+
+    @Override
+    protected void checkJobParamsInternal() {
+
+    }
+
+    @Override
+    public List<MTMVTask> createTasks(TaskType taskType) {
+        MTMVTask task = new MTMVTask(dbId, mtmvId);
+        task.setTaskType(taskType);
+        ArrayList<MTMVTask> tasks = new ArrayList<>();
+        tasks.add(task);
+        super.initTasks(tasks);
+        return tasks;
+    }
+
+    @Override
+    public boolean isReadyForScheduling() {
+        return CollectionUtils.isEmpty(getRunningTasks());
+    }
+
+    @Override
+    public ShowResultSetMetaData getJobMetaData() {
+        return JOB_META_DATA;
+    }
+
+    @Override
+    public ShowResultSetMetaData getTaskMetaData() {
+        return TASK_META_DATA;
+    }
+
+    @Override
+    public JobType getJobType() {
+        return JobType.MTMV;
+    }
+
+    @Override
+    public List<MTMVTask> queryTasks() {
+        MTMV mtmv = null;
+        try {
+            mtmv = getMTMV();
+        } catch (DdlException | MetaNotFoundException e) {
+            LOG.warn("get mtmv failed", e);
+            return Lists.newArrayList();
+        }
+        return mtmv.getJobInfo().getHistoryTasks();
+    }
+
+    @Override
+    public List<String> getShowInfo() {
+        List<String> data = Lists.newArrayList();
+        data.add(String.valueOf(super.getJobId()));
+        data.add(super.getJobName());
+        data.add(super.getJobConfig().getExecuteType().name());
+        data.add(super.getJobConfig().convertRecurringStrategyToString());
+        data.add(super.getJobStatus().name());
+        data.add(TimeUtils.longToTimeString(super.getCreateTimeMs()));
+        data.add(super.getComment());
+        return data;
+    }
+
+    private MTMV getMTMV() throws DdlException, MetaNotFoundException {
+        Database db = Env.getCurrentInternalCatalog().getDbOrDdlException(dbId);
+        return (MTMV) db.getTableOrMetaException(mtmvId, TableType.MATERIALIZED_VIEW);
+    }
+
+    @Override
+    public void write(DataOutput out) throws IOException {
+        Text.writeString(out, GsonUtils.GSON.toJson(this));
+    }
+
+}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/job/extensions/mtmv/MTMVTask.java b/fe/fe-core/src/main/java/org/apache/doris/job/extensions/mtmv/MTMVTask.java
new file mode 100644
index 00000000000..f4d92244289
--- /dev/null
+++ b/fe/fe-core/src/main/java/org/apache/doris/job/extensions/mtmv/MTMVTask.java
@@ -0,0 +1,169 @@
+// 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.
+
+package org.apache.doris.job.extensions.mtmv;
+
+import org.apache.doris.analysis.UserIdentity;
+import org.apache.doris.catalog.Database;
+import org.apache.doris.catalog.Env;
+import org.apache.doris.catalog.MTMV;
+import org.apache.doris.catalog.TableIf.TableType;
+import org.apache.doris.cluster.ClusterNamespace;
+import org.apache.doris.common.AnalysisException;
+import org.apache.doris.common.UserException;
+import org.apache.doris.common.util.TimeUtils;
+import org.apache.doris.datasource.CatalogIf;
+import org.apache.doris.job.exception.JobException;
+import org.apache.doris.job.task.AbstractTask;
+import org.apache.doris.mtmv.MTMVCacheManager;
+import org.apache.doris.mtmv.MTMVRelation;
+import org.apache.doris.mysql.privilege.Auth;
+import org.apache.doris.nereids.trees.plans.commands.info.TableNameInfo;
+import org.apache.doris.qe.ConnectContext;
+import org.apache.doris.qe.StmtExecutor;
+import org.apache.doris.system.SystemInfoService;
+import org.apache.doris.thrift.TUniqueId;
+
+import com.google.common.collect.Lists;
+import com.google.gson.annotations.SerializedName;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import java.util.List;
+import java.util.UUID;
+
+public class MTMVTask extends AbstractTask {
+    private static final Logger LOG = LogManager.getLogger(MTMVTask.class);
+    public static final Long MAX_HISTORY_TASKS_NUM = 100L;
+
+    @SerializedName(value = "di")
+    private long dbId;
+    @SerializedName(value = "mi")
+    private long mtmvId;
+    @SerializedName("sql")
+    private String sql;
+
+    private MTMV mtmv;
+    private MTMVRelation relation;
+
+    public MTMVTask(long dbId, long mtmvId) {
+        this.dbId = dbId;
+        this.mtmvId = mtmvId;
+    }
+
+    @Override
+    public void run() throws JobException {
+        try {
+            ConnectContext ctx = createContext();
+            TUniqueId queryId = generateQueryId();
+            // Every time a task is run, the relation is regenerated because baseTables and baseViews may change,
+            // such as deleting a table and creating a view with the same name
+            relation = MTMVCacheManager.generateMTMVRelation(mtmv, ctx);
+            StmtExecutor executor = new StmtExecutor(ctx, sql);
+            executor.execute(queryId);
+        } catch (Throwable e) {
+            LOG.warn(e);
+            throw new JobException(e);
+        }
+    }
+
+    @Override
+    public void onFail() throws JobException {
+        super.onFail();
+        after();
+    }
+
+    @Override
+    public void onSuccess() throws JobException {
+        super.onSuccess();
+        after();
+    }
+
+    @Override
+    public void cancel() throws JobException {
+        super.cancel();
+        after();
+    }
+
+    @Override
+    public void before() throws JobException {
+        super.before();
+        try {
+            Database db = Env.getCurrentInternalCatalog().getDbOrDdlException(dbId);
+            mtmv = (MTMV) db.getTableOrMetaException(mtmvId, TableType.MATERIALIZED_VIEW);
+            sql = generateSql(mtmv);
+        } catch (UserException e) {
+            LOG.warn(e);
+            throw new JobException(e);
+        }
+    }
+
+    @Override
+    public List<String> getShowInfo() {
+        List<String> data = Lists.newArrayList();
+        data.add(super.getJobId() + "");
+        data.add(super.getTaskId() + "");
+        data.add(super.getStatus() + "");
+        data.add(TimeUtils.longToTimeString(super.getCreateTimeMs()));
+        data.add(TimeUtils.longToTimeString(super.getStartTimeMs()));
+        data.add(TimeUtils.longToTimeString(super.getFinishTimeMs()));
+        data.add(String.valueOf(super.getFinishTimeMs() - super.getStartTimeMs()));
+        data.add(sql);
+        return data;
+    }
+
+    private static String generateSql(MTMV mtmv) {
+        StringBuilder builder = new StringBuilder();
+        builder.append("INSERT OVERWRITE TABLE ");
+        builder.append(mtmv.getDatabase().getCatalog().getName());
+        builder.append(".");
+        builder.append(ClusterNamespace.getNameFromFullName(mtmv.getQualifiedDbName()));
+        builder.append(".");
+        builder.append(mtmv.getName());
+        builder.append(" ");
+        builder.append(mtmv.getQuerySql());
+        return builder.toString();
+    }
+
+    private ConnectContext createContext() throws AnalysisException {
+        ConnectContext ctx = new ConnectContext();
+        ctx.setEnv(Env.getCurrentEnv());
+        ctx.setCluster(SystemInfoService.DEFAULT_CLUSTER);
+        ctx.setQualifiedUser(Auth.ADMIN_USER);
+        ctx.setCurrentUserIdentity(UserIdentity.ADMIN);
+        ctx.getState().reset();
+        ctx.setThreadLocalInfo();
+        CatalogIf catalog = Env.getCurrentEnv().getCatalogMgr()
+                .getCatalogOrAnalysisException(mtmv.getEnvInfo().getCtlId());
+        ctx.changeDefaultCatalog(catalog.getName());
+        ctx.setDatabase(catalog.getDbOrAnalysisException(mtmv.getEnvInfo().getDbId()).getFullName());
+        ctx.getSessionVariable().enableFallbackToOriginalPlanner = false;
+        return ctx;
+    }
+
+    private TUniqueId generateQueryId() {
+        UUID taskId = UUID.randomUUID();
+        return new TUniqueId(taskId.getMostSignificantBits(), taskId.getLeastSignificantBits());
+    }
+
+    private void after() {
+        Env.getCurrentEnv()
+                .addMTMVTaskResult(new TableNameInfo(mtmv.getQualifiedDbName(), mtmv.getName()), this, relation);
+        mtmv = null;
+        relation = null;
+    }
+}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/job/manager/JobManager.java b/fe/fe-core/src/main/java/org/apache/doris/job/manager/JobManager.java
index 0df87a84517..c7d04cdd282 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/job/manager/JobManager.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/job/manager/JobManager.java
@@ -17,6 +17,7 @@
 
 package org.apache.doris.job.manager;
 
+import org.apache.doris.catalog.Env;
 import org.apache.doris.common.io.Writable;
 import org.apache.doris.common.util.LogBuilder;
 import org.apache.doris.common.util.LogKey;
@@ -53,21 +54,19 @@ public class JobManager<T extends AbstractJob<?>> implements Writable {
 
     public void registerJob(T job) throws JobException {
         job.checkJobParams();
-        checkJobNameExist(job.getJobName(), job.getJobType(), job.getCurrentDbName());
+        checkJobNameExist(job.getJobName(), job.getJobType());
         if (jobMap.get(job.getJobId()) != null) {
             throw new JobException("job id exist,jobId:" + job.getJobId());
         }
-        //Env.getCurrentEnv().getEditLog().logCreateJob(job);
-        //check name exist
+        Env.getCurrentEnv().getEditLog().logCreateJob(job);
         jobMap.put(job.getJobId(), job);
         //check its need to scheduler
         jobScheduler.scheduleOneJob(job);
     }
 
 
-    private void checkJobNameExist(String jobName, JobType type, String currentDbName) throws JobException {
-        if (jobMap.values().stream().anyMatch(a -> a.getJobName().equals(jobName) && a.getJobType().equals(type)
-                && (null == a.getCurrentDbName() || a.getCurrentDbName().equals(currentDbName)))) {
+    private void checkJobNameExist(String jobName, JobType type) throws JobException {
+        if (jobMap.values().stream().anyMatch(a -> a.getJobName().equals(jobName) && a.getJobType().equals(type))) {
             throw new JobException("job name exist,jobName:" + jobName);
         }
     }
@@ -75,15 +74,14 @@ public class JobManager<T extends AbstractJob<?>> implements Writable {
     public void unregisterJob(Long jobId) throws JobException {
         checkJobExist(jobId);
         jobMap.get(jobId).setJobStatus(JobStatus.STOPPED);
-        jobMap.get(jobId).cancel();
-        //Env.getCurrentEnv().getEditLog().logDeleteJob(jobMap.get(jobId));
+        jobMap.get(jobId).cancelAllTasks();
+        Env.getCurrentEnv().getEditLog().logDeleteJob(jobMap.get(jobId));
         jobMap.remove(jobId);
     }
 
-    public void unregisterJob(String currentDbName, String jobName) throws JobException {
+    public void unregisterJob(String jobName, JobType jobType) throws JobException {
         for (T a : jobMap.values()) {
-            if (a.getJobName().equals(jobName) && (null != a.getCurrentDbName()
-                    && a.getCurrentDbName().equals(currentDbName)) && a.getJobType().equals(JobType.INSERT)) {
+            if (a.getJobName().equals(jobName) && a.getJobType().equals(jobType)) {
                 try {
                     unregisterJob(a.getJobId());
                 } catch (JobException e) {
@@ -97,13 +95,12 @@ public class JobManager<T extends AbstractJob<?>> implements Writable {
     public void alterJobStatus(Long jobId, JobStatus status) throws JobException {
         checkJobExist(jobId);
         jobMap.get(jobId).updateJobStatus(status);
-        //Env.getCurrentEnv().getEditLog().logUpdateJob(jobMap.get(jobId));
+        Env.getCurrentEnv().getEditLog().logUpdateJob(jobMap.get(jobId));
     }
 
-    public void alterJobStatus(String currentDbName, String jobName, JobStatus jobStatus) throws JobException {
+    public void alterJobStatus(String jobName, JobStatus jobStatus, JobType jobType) throws JobException {
         for (T a : jobMap.values()) {
-            if (a.getJobName().equals(jobName) && (null != a.getCurrentDbName()
-                    && a.getCurrentDbName().equals(currentDbName)) && JobType.INSERT.equals(a.getJobType())) {
+            if (a.getJobName().equals(jobName) && jobType.equals(a.getJobType())) {
                 try {
                     alterJobStatus(a.getJobId(), jobStatus);
                 } catch (JobException e) {
@@ -124,19 +121,37 @@ public class JobManager<T extends AbstractJob<?>> implements Writable {
                 .collect(java.util.stream.Collectors.toList());
     }
 
-    public List<T> queryJobs(String currentDb, String jobName) {
+    public List<T> queryJobs(JobType jobType, String jobName) {
         //only query insert job,we just provide insert job
-        return jobMap.values().stream().filter(a -> checkItsMatch(currentDb, jobName, a))
+        return jobMap.values().stream().filter(a -> checkItsMatch(jobType, jobName, a))
                 .collect(Collectors.toList());
     }
 
-    private boolean checkItsMatch(String currentDb, String jobName, T job) {
+    /**
+     * query jobs by job type
+     * @param jobTypes @JobType
+     * @return List<AbstractJob> job list
+     */
+    public List<T> queryJobs(List<JobType> jobTypes) {
+        return jobMap.values().stream().filter(a -> checkItsMatch(jobTypes, a))
+                .collect(Collectors.toList());
+    }
+
+    private boolean checkItsMatch(JobType jobType, String jobName, T job) {
+        if (null == jobType) {
+            throw new IllegalArgumentException("jobType cannot be null");
+        }
         if (StringUtils.isBlank(jobName)) {
-            return job.getJobType().equals(JobType.INSERT) && (null != job.getCurrentDbName()
-                    && job.getCurrentDbName().equals(currentDb));
+            return job.getJobType().equals(jobType);
+        }
+        return job.getJobType().equals(jobType) && job.getJobName().equals(jobName);
+    }
+
+    private boolean checkItsMatch(List<JobType> jobTypes, T job) {
+        if (null == jobTypes) {
+            throw new IllegalArgumentException("jobType cannot be null");
         }
-        return job.getJobType().equals(JobType.INSERT) && (null != job.getCurrentDbName()
-                && job.getCurrentDbName().equals(currentDb)) && job.getJobName().equals(jobName);
+        return jobTypes.contains(job.getJobType());
     }
 
     public List<? extends AbstractTask> queryTasks(Long jobId) throws JobException {
diff --git a/fe/fe-core/src/main/java/org/apache/doris/job/manager/TaskDisruptorGroupManager.java b/fe/fe-core/src/main/java/org/apache/doris/job/manager/TaskDisruptorGroupManager.java
index 1becb12d70b..97a6f94099f 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/job/manager/TaskDisruptorGroupManager.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/job/manager/TaskDisruptorGroupManager.java
@@ -28,6 +28,7 @@ import org.apache.doris.job.disruptor.TimerJobEvent;
 import org.apache.doris.job.executor.DefaultTaskExecutorHandler;
 import org.apache.doris.job.executor.DispatchTaskHandler;
 import org.apache.doris.job.extensions.insert.InsertTask;
+import org.apache.doris.job.extensions.mtmv.MTMVTask;
 import org.apache.doris.job.task.AbstractTask;
 
 import com.lmax.disruptor.BlockingWaitStrategy;
@@ -58,13 +59,18 @@ public class TaskDisruptorGroupManager<T extends AbstractTask> {
             ? Config.job_dispatch_timer_job_thread_num : DEFAULT_CONSUMER_THREAD_NUM;
 
     private static final int DISPATCH_INSERT_THREAD_NUM = Config.job_insert_task_consumer_thread_num > 0
-            ? Config.job_insert_task_consumer_thread_num : DEFAULT_RING_BUFFER_SIZE;
+            ? Config.job_insert_task_consumer_thread_num : DEFAULT_CONSUMER_THREAD_NUM;
+
+    private static final int DISPATCH_MTMV_THREAD_NUM = Config.job_mtmv_task_consumer_thread_num > 0
+            ? Config.job_mtmv_task_consumer_thread_num : DEFAULT_CONSUMER_THREAD_NUM;
 
     private static final int DISPATCH_INSERT_TASK_QUEUE_SIZE = DEFAULT_RING_BUFFER_SIZE;
+    private static final int DISPATCH_MTMV_TASK_QUEUE_SIZE = DEFAULT_RING_BUFFER_SIZE;
 
 
     public void init() {
         registerInsertDisruptor();
+        registerMTMVDisruptor();
         //when all task queue is ready, dispatch task to registered task executor
         registerDispatchDisruptor();
     }
@@ -100,6 +106,23 @@ public class TaskDisruptorGroupManager<T extends AbstractTask> {
         disruptorMap.put(JobType.INSERT, insertDisruptor);
     }
 
+    private void registerMTMVDisruptor() {
+        EventFactory<ExecuteTaskEvent<MTMVTask>> mtmvEventFactory = ExecuteTaskEvent.factory();
+        ThreadFactory mtmvTaskThreadFactory = new CustomThreadFactory("mtmv-task-execute");
+        WorkHandler[] insertTaskExecutorHandlers = new WorkHandler[DISPATCH_MTMV_THREAD_NUM];
+        for (int i = 0; i < DISPATCH_MTMV_THREAD_NUM; i++) {
+            insertTaskExecutorHandlers[i] = new DefaultTaskExecutorHandler<MTMVTask>();
+        }
+        EventTranslatorVararg<ExecuteTaskEvent<MTMVTask>> eventTranslator =
+                (event, sequence, args) -> {
+                    event.setTask((MTMVTask) args[0]);
+                    event.setJobConfig((JobExecutionConfiguration) args[1]);
+                };
+        TaskDisruptor mtmvDisruptor = new TaskDisruptor<>(mtmvEventFactory, DISPATCH_MTMV_TASK_QUEUE_SIZE,
+                mtmvTaskThreadFactory, new BlockingWaitStrategy(), insertTaskExecutorHandlers, eventTranslator);
+        disruptorMap.put(JobType.MTMV, mtmvDisruptor);
+    }
+
     public void dispatchTimerJob(AbstractJob<T> job) {
         dispatchDisruptor.publishEvent(job);
     }
diff --git a/fe/fe-core/src/main/java/org/apache/doris/job/scheduler/JobScheduler.java b/fe/fe-core/src/main/java/org/apache/doris/job/scheduler/JobScheduler.java
index a9cedc99947..c701c9fd1f8 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/job/scheduler/JobScheduler.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/job/scheduler/JobScheduler.java
@@ -53,7 +53,7 @@ public class JobScheduler<T extends AbstractJob<?>> implements Closeable {
 
     private long latestBatchSchedulerTimerTaskTimeMs = 0L;
 
-    private static final long BATCH_SCHEDULER_INTERVAL_SECONDS = 60;
+    private static final long BATCH_SCHEDULER_INTERVAL_SECONDS = 600;
 
     private static final int HASHED_WHEEL_TIMER_TICKS_PER_WHEEL = 660;
 
@@ -104,13 +104,22 @@ public class JobScheduler<T extends AbstractJob<?>> implements Closeable {
         if (!job.getJobConfig().checkIsTimerJob()) {
             //manual job will not scheduler
             if (JobExecuteType.MANUAL.equals(job.getJobConfig().getExecuteType())) {
+                if (job.getJobConfig().isImmediate()) {
+                    schedulerInstantJob(job, TaskType.MANUAL);
+                }
                 return;
             }
+
             //todo skip streaming job,improve in the future
             if (JobExecuteType.INSTANT.equals(job.getJobConfig().getExecuteType())) {
                 schedulerInstantJob(job, TaskType.SCHEDULED);
             }
         }
+        //RECURRING job and  immediate is true
+        if (job.getJobConfig().isImmediate()) {
+            job.getJobConfig().getTimerDefinition().setLatestSchedulerTimeMs(System.currentTimeMillis());
+            schedulerInstantJob(job, TaskType.SCHEDULED);
+        }
         //if it's timer job and trigger last window already start, we will scheduler it immediately
         cycleTimerJobScheduler(job);
     }
diff --git a/fe/fe-core/src/main/java/org/apache/doris/job/task/AbstractTask.java b/fe/fe-core/src/main/java/org/apache/doris/job/task/AbstractTask.java
index 7fc666339af..4580456928f 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/job/task/AbstractTask.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/job/task/AbstractTask.java
@@ -21,7 +21,9 @@ import org.apache.doris.catalog.Env;
 import org.apache.doris.job.base.Job;
 import org.apache.doris.job.common.TaskStatus;
 import org.apache.doris.job.common.TaskType;
+import org.apache.doris.job.exception.JobException;
 
+import com.google.gson.annotations.SerializedName;
 import lombok.Data;
 import lombok.extern.slf4j.Slf4j;
 
@@ -29,31 +31,38 @@ import lombok.extern.slf4j.Slf4j;
 @Slf4j
 public abstract class AbstractTask implements Task {
 
+    @SerializedName(value = "jid")
     private Long jobId;
-
+    @SerializedName(value = "tid")
     private Long taskId;
 
+    @SerializedName(value = "st")
     private TaskStatus status;
-
+    @SerializedName(value = "ctm")
     private Long createTimeMs;
-
+    @SerializedName(value = "stm")
     private Long startTimeMs;
-
+    @SerializedName(value = "ftm")
     private Long finishTimeMs;
 
+    @SerializedName(value = "tt")
     private TaskType taskType;
 
     @Override
     public void onFail(String msg) {
+        status = TaskStatus.FAILD;
         if (!isCallable()) {
             return;
         }
         Env.getCurrentEnv().getJobManager().getJob(jobId).onTaskFail(this);
-        status = TaskStatus.FAILD;
     }
 
     @Override
-    public void onFail() {
+    public void onFail() throws JobException {
+        if (TaskStatus.CANCEL.equals(status)) {
+            return;
+        }
+        status = TaskStatus.FAILD;
         setFinishTimeMs(System.currentTimeMillis());
         if (!isCallable()) {
             return;
@@ -73,7 +82,7 @@ public abstract class AbstractTask implements Task {
     }
 
     @Override
-    public void onSuccess() {
+    public void onSuccess() throws JobException {
         status = TaskStatus.SUCCESS;
         setFinishTimeMs(System.currentTimeMillis());
         if (!isCallable()) {
@@ -88,17 +97,17 @@ public abstract class AbstractTask implements Task {
     }
 
     @Override
-    public void cancel() {
+    public void cancel() throws JobException {
         status = TaskStatus.CANCEL;
     }
 
     @Override
-    public void before() {
+    public void before() throws JobException {
         status = TaskStatus.RUNNING;
         setStartTimeMs(System.currentTimeMillis());
     }
 
-    public void runTask() {
+    public void runTask() throws JobException {
         try {
             before();
             run();
diff --git a/fe/fe-core/src/main/java/org/apache/doris/job/task/Task.java b/fe/fe-core/src/main/java/org/apache/doris/job/task/Task.java
index 350c562f7e8..3f61ce60c70 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/job/task/Task.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/job/task/Task.java
@@ -17,6 +17,10 @@
 
 package org.apache.doris.job.task;
 
+import org.apache.doris.job.exception.JobException;
+
+import java.util.List;
+
 /**
  * The Task interface represents a task that can be executed and managed by a scheduler.
  * All extension tasks must implement this interface.
@@ -29,19 +33,19 @@ public interface Task {
      * This method is called before the task is executed.
      * Implementations can use this method to perform any necessary setup or initialization.
      */
-    void before();
+    void before() throws JobException;
 
     /**
      * This method contains the main logic of the task.
      * Implementations should define the specific actions to be performed by the task.
      */
-    void run();
+    void run() throws JobException;
 
     /**
      * This method is called when the task fails to execute successfully.
      * Implementations can use this method to handle any failure scenarios.
      */
-    void onFail();
+    void onFail() throws JobException;
 
     /**
      * This method is called when the task fails to execute successfully, with an additional error message.
@@ -55,12 +59,17 @@ public interface Task {
      * This method is called when the task executes successfully.
      * Implementations can use this method to handle successful execution scenarios.
      */
-    void onSuccess();
+    void onSuccess() throws JobException;
 
     /**
      * This method is called to cancel the execution of the task.
      * Implementations should define the necessary steps to cancel the task.
      */
-    void cancel();
+    void cancel() throws JobException;
 
+    /**
+     * get the job's show info, which is used to sql show the task information
+     * @return List<String> task common show info
+     */
+    List<String> getShowInfo();
 }
diff --git a/fe/fe-core/src/main/java/org/apache/doris/journal/JournalEntity.java b/fe/fe-core/src/main/java/org/apache/doris/journal/JournalEntity.java
index 162e8b3cc88..b0749db1fe1 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/journal/JournalEntity.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/journal/JournalEntity.java
@@ -59,6 +59,7 @@ import org.apache.doris.load.sync.SyncJob;
 import org.apache.doris.mysql.privilege.UserPropertyInfo;
 import org.apache.doris.persist.AlterDatabasePropertyInfo;
 import org.apache.doris.persist.AlterLightSchemaChangeInfo;
+import org.apache.doris.persist.AlterMTMV;
 import org.apache.doris.persist.AlterRoutineLoadJobOperationLog;
 import org.apache.doris.persist.AlterUserOperationLog;
 import org.apache.doris.persist.AlterViewInfo;
@@ -870,6 +871,11 @@ public class JournalEntity implements Writable {
                 isRead = true;
                 break;
             }
+            case OperationType.OP_ALTER_MTMV: {
+                data = AlterMTMV.read(in);
+                isRead = true;
+                break;
+            }
             default: {
                 IOException e = new IOException();
                 LOG.error("UNKNOWN Operation Type {}", opCode, e);
diff --git a/fe/fe-core/src/main/java/org/apache/doris/load/EtlJobType.java b/fe/fe-core/src/main/java/org/apache/doris/load/EtlJobType.java
index d00dc21b846..2770738d3d7 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/load/EtlJobType.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/load/EtlJobType.java
@@ -25,5 +25,7 @@ public enum EtlJobType {
     DELETE,
     SPARK,
     LOCAL_FILE,
+    // create by job scheduler,inner use
+    INSERT_JOB,
     UNKNOWN
 }
diff --git a/fe/fe-core/src/main/java/org/apache/doris/load/loadv2/BrokerLoadJob.java b/fe/fe-core/src/main/java/org/apache/doris/load/loadv2/BrokerLoadJob.java
index 82187858492..fd416b8e449 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/load/loadv2/BrokerLoadJob.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/load/loadv2/BrokerLoadJob.java
@@ -404,7 +404,7 @@ public class BrokerLoadJob extends BulkLoadJob {
     }
 
     @Override
-    protected String getResourceName() {
+    public String getResourceName() {
         StorageBackend.StorageType storageType = brokerDesc.getStorageType();
         if (storageType == StorageBackend.StorageType.BROKER) {
             return brokerDesc.getName();
diff --git a/fe/fe-core/src/main/java/org/apache/doris/load/loadv2/InsertLoadJob.java b/fe/fe-core/src/main/java/org/apache/doris/load/loadv2/InsertLoadJob.java
index 62b108d7f49..19814036ec4 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/load/loadv2/InsertLoadJob.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/load/loadv2/InsertLoadJob.java
@@ -73,6 +73,28 @@ public class InsertLoadJob extends LoadJob {
         this.userInfo = userInfo;
     }
 
+    public InsertLoadJob(String label, long transactionId, long dbId, long tableId,
+                         long createTimestamp, String failMsg, String trackingUrl,
+                         UserIdentity userInfo, Long jobId) throws MetaNotFoundException {
+        super(EtlJobType.INSERT_JOB, dbId, label, jobId);
+        this.tableId = tableId;
+        this.transactionId = transactionId;
+        this.createTimestamp = createTimestamp;
+        this.loadStartTimestamp = createTimestamp;
+        this.finishTimestamp = System.currentTimeMillis();
+        if (Strings.isNullOrEmpty(failMsg)) {
+            this.state = JobState.FINISHED;
+            this.progress = 100;
+        } else {
+            this.state = JobState.CANCELLED;
+            this.failMsg = new FailMsg(CancelType.LOAD_RUN_FAIL, failMsg);
+            this.progress = 0;
+        }
+        this.authorizationInfo = gatherAuthInfo();
+        this.loadingStatus.setTrackingUrl(trackingUrl);
+        this.userInfo = userInfo;
+    }
+
     public AuthorizationInfo gatherAuthInfo() throws MetaNotFoundException {
         Database database = Env.getCurrentInternalCatalog().getDbOrMetaException(dbId);
         return new AuthorizationInfo(database.getFullName(), getTableNames());
diff --git a/fe/fe-core/src/main/java/org/apache/doris/load/loadv2/LoadJob.java b/fe/fe-core/src/main/java/org/apache/doris/load/loadv2/LoadJob.java
index 2c70883d8f1..bd8d09d5c60 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/load/loadv2/LoadJob.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/load/loadv2/LoadJob.java
@@ -253,6 +253,13 @@ public abstract class LoadJob extends AbstractTxnStateChangeCallback implements
         this.label = label;
     }
 
+    public LoadJob(EtlJobType jobType, long dbId, String label, long jobId) {
+        this(jobType);
+        this.id = jobId;
+        this.dbId = dbId;
+        this.label = label;
+    }
+
     protected void readLock() {
         lock.readLock().lock();
     }
@@ -837,7 +844,7 @@ public abstract class LoadJob extends AbstractTxnStateChangeCallback implements
         return gson.toJson(map);
     }
 
-    protected String getResourceName() {
+    public String getResourceName() {
         return "N/A";
     }
 
@@ -864,7 +871,7 @@ public abstract class LoadJob extends AbstractTxnStateChangeCallback implements
             job = new BrokerLoadJob();
         } else if (type == EtlJobType.SPARK) {
             job = new SparkLoadJob();
-        } else if (type == EtlJobType.INSERT) {
+        } else if (type == EtlJobType.INSERT || type == EtlJobType.INSERT_JOB) {
             job = new InsertLoadJob();
         } else if (type == EtlJobType.MINI) {
             job = new MiniLoadJob();
@@ -1194,7 +1201,7 @@ public abstract class LoadJob extends AbstractTxnStateChangeCallback implements
     }
 
     // unit: second
-    protected long getTimeout() {
+    public long getTimeout() {
         return (long) jobProperties.get(LoadStmt.TIMEOUT_PROPERTY);
     }
 
@@ -1206,7 +1213,7 @@ public abstract class LoadJob extends AbstractTxnStateChangeCallback implements
         return (long) jobProperties.get(LoadStmt.EXEC_MEM_LIMIT);
     }
 
-    protected double getMaxFilterRatio() {
+    public double getMaxFilterRatio() {
         return (double) jobProperties.get(LoadStmt.MAX_FILTER_RATIO_PROPERTY);
     }
 
diff --git a/fe/fe-core/src/main/java/org/apache/doris/load/loadv2/LoadManager.java b/fe/fe-core/src/main/java/org/apache/doris/load/loadv2/LoadManager.java
index 009c5144fad..3eacb9f66c4 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/load/loadv2/LoadManager.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/load/loadv2/LoadManager.java
@@ -56,6 +56,7 @@ import com.google.common.base.Strings;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
+import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
@@ -213,8 +214,8 @@ public class LoadManager implements Writable {
      * Record finished load job by editLog.
      **/
     public void recordFinishedLoadJob(String label, long transactionId, String dbName, long tableId, EtlJobType jobType,
-            long createTimestamp, String failMsg, String trackingUrl,
-            UserIdentity userInfo) throws MetaNotFoundException {
+                                      long createTimestamp, String failMsg, String trackingUrl,
+                                      UserIdentity userInfo, long jobId) throws MetaNotFoundException {
 
         // get db id
         Database db = Env.getCurrentInternalCatalog().getDbOrMetaException(dbName);
@@ -225,6 +226,10 @@ public class LoadManager implements Writable {
                 loadJob = new InsertLoadJob(label, transactionId, db.getId(), tableId, createTimestamp, failMsg,
                         trackingUrl, userInfo);
                 break;
+            case INSERT_JOB:
+                loadJob = new InsertLoadJob(label, transactionId, db.getId(), tableId, createTimestamp, failMsg,
+                        trackingUrl, userInfo, jobId);
+                break;
             default:
                 return;
         }
@@ -504,16 +509,16 @@ public class LoadManager implements Writable {
     /**
      * This method will return the jobs info which can meet the condition of input param.
      *
-     * @param dbId used to filter jobs which belong to this db
-     * @param labelValue used to filter jobs which's label is or like labelValue.
+     * @param dbId          used to filter jobs which belong to this db
+     * @param labelValue    used to filter jobs which's label is or like labelValue.
      * @param accurateMatch true: filter jobs which's label is labelValue. false: filter jobs which's label like itself.
-     * @param statesValue used to filter jobs which's state within the statesValue set.
+     * @param statesValue   used to filter jobs which's state within the statesValue set.
      * @return The result is the list of jobInfo.
      * JobInfo is a list which includes the comparable object: jobId, label, state etc.
      * The result is unordered.
      */
     public List<List<Comparable>> getLoadJobInfosByDb(long dbId, String labelValue, boolean accurateMatch,
-            Set<String> statesValue) throws AnalysisException {
+                                                      Set<String> statesValue) throws AnalysisException {
         LinkedList<List<Comparable>> loadJobInfos = new LinkedList<List<Comparable>>();
         if (!dbIdToLabelToLoadJobs.containsKey(dbId)) {
             return loadJobInfos;
@@ -641,6 +646,19 @@ public class LoadManager implements Writable {
         return idToLoadJob.get(jobId);
     }
 
+    public List<LoadJob> queryLoadJobsByJobIds(List<Long> jobIds) {
+        if (CollectionUtils.isEmpty(jobIds)) {
+            return new ArrayList<>();
+        }
+        List<LoadJob> jobs = new ArrayList<>();
+        jobIds.forEach(id -> {
+            if (null != idToLoadJob.get(id)) {
+                jobs.add(idToLoadJob.get(id));
+            }
+        });
+        return jobs;
+    }
+
     public void prepareJobs() {
         analyzeLoadJobs();
         submitJobs();
@@ -797,7 +815,7 @@ public class LoadManager implements Writable {
      * Init.
      **/
     public void initJobProgress(Long jobId, TUniqueId loadId, Set<TUniqueId> fragmentIds,
-            List<Long> relatedBackendIds) {
+                                List<Long> relatedBackendIds) {
         LoadJob job = idToLoadJob.get(jobId);
         if (job != null) {
             job.initLoadProgress(loadId, fragmentIds, relatedBackendIds);
@@ -808,7 +826,7 @@ public class LoadManager implements Writable {
      * Update.
      **/
     public void updateJobProgress(Long jobId, Long beId, TUniqueId loadId, TUniqueId fragmentId, long scannedRows,
-            long scannedBytes, boolean isDone) {
+                                  long scannedBytes, boolean isDone) {
         LoadJob job = idToLoadJob.get(jobId);
         if (job != null) {
             job.updateProgress(beId, loadId, fragmentId, scannedRows, scannedBytes, isDone);
diff --git a/fe/fe-core/src/main/java/org/apache/doris/load/loadv2/SparkLoadJob.java b/fe/fe-core/src/main/java/org/apache/doris/load/loadv2/SparkLoadJob.java
index 09a85d3dffe..69e1420ff34 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/load/loadv2/SparkLoadJob.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/load/loadv2/SparkLoadJob.java
@@ -743,7 +743,7 @@ public class SparkLoadJob extends BulkLoadJob {
     }
 
     @Override
-    protected String getResourceName() {
+    public String getResourceName() {
         return sparkResource.getName();
     }
 
diff --git a/fe/fe-core/src/main/java/org/apache/doris/mtmv/BaseTableInfo.java b/fe/fe-core/src/main/java/org/apache/doris/mtmv/BaseTableInfo.java
new file mode 100644
index 00000000000..575552cb61e
--- /dev/null
+++ b/fe/fe-core/src/main/java/org/apache/doris/mtmv/BaseTableInfo.java
@@ -0,0 +1,91 @@
+// 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.
+
+package org.apache.doris.mtmv;
+
+import org.apache.doris.catalog.DatabaseIf;
+import org.apache.doris.catalog.TableIf;
+import org.apache.doris.datasource.CatalogIf;
+import org.apache.doris.datasource.InternalCatalog;
+
+import com.google.common.base.Objects;
+import com.google.gson.annotations.SerializedName;
+
+public class BaseTableInfo {
+    @SerializedName("ti")
+    private Long tableId;
+    @SerializedName("di")
+    private Long dbId;
+    @SerializedName("ci")
+    private Long ctlId;
+
+    public BaseTableInfo(Long tableId, Long dbId) {
+        this.tableId = java.util.Objects.requireNonNull(tableId, "tableId is null");
+        this.dbId = java.util.Objects.requireNonNull(dbId, "dbId is null");
+        this.ctlId = InternalCatalog.INTERNAL_CATALOG_ID;
+    }
+
+    public BaseTableInfo(TableIf table) {
+        DatabaseIf database = table.getDatabase();
+        java.util.Objects.requireNonNull(database, "database is null");
+        CatalogIf catalog = database.getCatalog();
+        java.util.Objects.requireNonNull(database, "catalog is null");
+        this.tableId = table.getId();
+        this.dbId = database.getId();
+        this.ctlId = catalog.getId();
+    }
+
+    public Long getTableId() {
+        return tableId;
+    }
+
+    public Long getDbId() {
+        return dbId;
+    }
+
+    public Long getCtlId() {
+        return ctlId;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+        BaseTableInfo that = (BaseTableInfo) o;
+        return Objects.equal(tableId, that.tableId)
+                && Objects.equal(dbId, that.dbId)
+                && Objects.equal(ctlId, that.ctlId);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hashCode(tableId, dbId, ctlId);
+    }
+
+    @Override
+    public String toString() {
+        return "BaseTableInfo{"
+                + "tableId=" + tableId
+                + ", dbId=" + dbId
+                + ", ctlId=" + ctlId
+                + '}';
+    }
+}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/mtmv/EnvInfo.java b/fe/fe-core/src/main/java/org/apache/doris/mtmv/EnvInfo.java
index c5c92a15db9..97ad491cb31 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/mtmv/EnvInfo.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/mtmv/EnvInfo.java
@@ -23,21 +23,29 @@ import com.google.gson.annotations.SerializedName;
  * EnvInfo
  */
 public class EnvInfo {
-    @SerializedName("cn")
-    private String ctlName;
-    @SerializedName("dn")
-    private String dbName;
+    @SerializedName("ci")
+    private long ctlId;
+    @SerializedName("di")
+    private long dbId;
 
-    public EnvInfo(String ctlName, String dbName) {
-        this.ctlName = ctlName;
-        this.dbName = dbName;
+    public EnvInfo(long ctlId, long dbId) {
+        this.ctlId = ctlId;
+        this.dbId = dbId;
     }
 
-    public String getCtlName() {
-        return ctlName;
+    public long getCtlId() {
+        return ctlId;
     }
 
-    public String getDbName() {
-        return dbName;
+    public long getDbId() {
+        return dbId;
+    }
+
+    @Override
+    public String toString() {
+        return "EnvInfo{"
+                + "ctlId='" + ctlId + '\''
+                + ", dbId='" + dbId + '\''
+                + '}';
     }
 }
diff --git a/fe/fe-core/src/main/java/org/apache/doris/load/EtlJobType.java b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVAlterOpType.java
similarity index 80%
copy from fe/fe-core/src/main/java/org/apache/doris/load/EtlJobType.java
copy to fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVAlterOpType.java
index d00dc21b846..99f056d4224 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/load/EtlJobType.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVAlterOpType.java
@@ -15,15 +15,11 @@
 // specific language governing permissions and limitations
 // under the License.
 
-package org.apache.doris.load;
+package org.apache.doris.mtmv;
 
-public enum EtlJobType {
-    HADOOP, // not used any more
-    MINI,   // not used any more
-    INSERT,
-    BROKER,
-    DELETE,
-    SPARK,
-    LOCAL_FILE,
-    UNKNOWN
+public enum MTMVAlterOpType {
+    ALTER_REFRESH_INFO,
+    ALTER_STATUS,
+    ALTER_PROPERTY,
+    ADD_TASK;
 }
diff --git a/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVCacheManager.java b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVCacheManager.java
new file mode 100644
index 00000000000..847f85b9074
--- /dev/null
+++ b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVCacheManager.java
@@ -0,0 +1,312 @@
+// 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.
+
+package org.apache.doris.mtmv;
+
+import org.apache.doris.analysis.StatementBase;
+import org.apache.doris.catalog.Env;
+import org.apache.doris.catalog.MTMV;
+import org.apache.doris.catalog.OlapTable;
+import org.apache.doris.catalog.Partition;
+import org.apache.doris.catalog.Table;
+import org.apache.doris.catalog.TableIf;
+import org.apache.doris.catalog.TableIf.TableType;
+import org.apache.doris.common.AnalysisException;
+import org.apache.doris.common.DdlException;
+import org.apache.doris.common.MetaNotFoundException;
+import org.apache.doris.datasource.InternalCatalog;
+import org.apache.doris.job.common.TaskStatus;
+import org.apache.doris.job.extensions.mtmv.MTMVTask;
+import org.apache.doris.mtmv.MTMVRefreshEnum.MTMVRefreshState;
+import org.apache.doris.mtmv.MTMVRefreshEnum.MTMVState;
+import org.apache.doris.nereids.NereidsPlanner;
+import org.apache.doris.nereids.exceptions.ParseException;
+import org.apache.doris.nereids.glue.LogicalPlanAdapter;
+import org.apache.doris.nereids.parser.NereidsParser;
+import org.apache.doris.nereids.properties.PhysicalProperties;
+import org.apache.doris.nereids.trees.plans.Plan;
+import org.apache.doris.nereids.trees.plans.commands.ExplainCommand.ExplainLevel;
+import org.apache.doris.nereids.trees.plans.commands.info.RefreshMTMVInfo;
+import org.apache.doris.nereids.trees.plans.commands.info.TableNameInfo;
+import org.apache.doris.nereids.trees.plans.logical.LogicalPlan;
+import org.apache.doris.nereids.trees.plans.visitor.TableCollector;
+import org.apache.doris.nereids.trees.plans.visitor.TableCollector.TableCollectorContext;
+import org.apache.doris.persist.AlterMTMV;
+import org.apache.doris.qe.ConnectContext;
+
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+
+/**
+ * when do some operation, do something about cache
+ */
+public class MTMVCacheManager implements MTMVHookService {
+    private static final Logger LOG = LogManager.getLogger(MTMVCacheManager.class);
+    private Map<BaseTableInfo, Set<BaseTableInfo>> tableMTMVs = Maps.newConcurrentMap();
+
+    public Set<BaseTableInfo> getMtmvsByBaseTable(BaseTableInfo table) {
+        return tableMTMVs.get(table);
+    }
+
+    public boolean isAvailableMTMV(MTMV mtmv, ConnectContext ctx) throws AnalysisException, DdlException {
+        // check session variable if enable rewrite
+        if (!ctx.getSessionVariable().isEnableMvRewrite()) {
+            return false;
+        }
+        MTMVRelation mtmvRelation = mtmv.getRelation();
+        if (mtmvRelation == null) {
+            return false;
+        }
+        // chaek mv is normal
+        if (!(mtmv.getStatus().getState() == MTMVState.NORMAL
+                && mtmv.getStatus().getRefreshState() == MTMVRefreshState.SUCCESS)) {
+            return false;
+        }
+        // check external table
+        boolean containsExternalTable = containsExternalTable(mtmvRelation.getBaseTables());
+        if (containsExternalTable) {
+            return ctx.getSessionVariable().isEnableExternalMvRewrite();
+        }
+        // check gracePeriod
+        Long gracePeriod = mtmv.getGracePeriod();
+        // do not care data is delayed
+        if (gracePeriod < 0) {
+            return true;
+        }
+        // compare with base table
+        Long mtmvLastTime = getTableLastVisibleVersionTime(mtmv);
+        Long maxAvailableTime = mtmvLastTime + gracePeriod;
+        for (BaseTableInfo baseTableInfo : mtmvRelation.getBaseTables()) {
+            long tableLastVisibleVersionTime = getTableLastVisibleVersionTime(baseTableInfo);
+            if (tableLastVisibleVersionTime > maxAvailableTime) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    private long getTableLastVisibleVersionTime(BaseTableInfo baseTableInfo) throws AnalysisException, DdlException {
+        Table table = Env.getCurrentEnv().getInternalCatalog()
+                .getDbOrAnalysisException(baseTableInfo.getDbId())
+                .getTableOrDdlException(baseTableInfo.getTableId(), TableType.OLAP);
+        return getTableLastVisibleVersionTime((OlapTable) table);
+    }
+
+    private long getTableLastVisibleVersionTime(OlapTable table) {
+        long result = 0L;
+        long visibleVersionTime;
+        for (Partition partition : table.getAllPartitions()) {
+            visibleVersionTime = partition.getVisibleVersionTime();
+            if (visibleVersionTime > result) {
+                result = visibleVersionTime;
+            }
+        }
+        return result;
+    }
+
+    private boolean containsExternalTable(Set<BaseTableInfo> baseTableInfos) {
+        for (BaseTableInfo baseTableInfo : baseTableInfos) {
+            if (InternalCatalog.INTERNAL_CATALOG_ID != baseTableInfo.getCtlId()) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    public static MTMVRelation generateMTMVRelation(MTMV mtmv, ConnectContext ctx) {
+        Plan plan = getPlanBySql(mtmv.getQuerySql(), ctx);
+        return new MTMVRelation(getBaseTables(plan), getBaseViews(plan));
+    }
+
+    private static Set<BaseTableInfo> getBaseTables(Plan plan) {
+        TableCollectorContext collectorContext =
+                new TableCollector.TableCollectorContext(
+                        Sets.newHashSet(TableType.MATERIALIZED_VIEW, TableType.OLAP));
+        plan.accept(TableCollector.INSTANCE, collectorContext);
+        List<TableIf> collectedTables = collectorContext.getCollectedTables();
+        return transferTableIfToInfo(collectedTables);
+    }
+
+    private static Set<BaseTableInfo> getBaseViews(Plan plan) {
+        TableCollectorContext collectorContext =
+                new TableCollector.TableCollectorContext(
+                        Sets.newHashSet(TableType.VIEW));
+        plan.accept(TableCollector.INSTANCE, collectorContext);
+        List<TableIf> collectedTables = collectorContext.getCollectedTables();
+        return transferTableIfToInfo(collectedTables);
+    }
+
+    private static Set<BaseTableInfo> transferTableIfToInfo(List<TableIf> tables) {
+        Set<BaseTableInfo> result = Sets.newHashSet();
+        for (TableIf table : tables) {
+            result.add(new BaseTableInfo(table));
+        }
+        return result;
+    }
+
+    private static Plan getPlanBySql(String querySql, ConnectContext ctx) {
+        List<StatementBase> statements;
+        try {
+            statements = new NereidsParser().parseSQL(querySql);
+        } catch (Exception e) {
+            throw new ParseException("Nereids parse failed. " + e.getMessage());
+        }
+        StatementBase parsedStmt = statements.get(0);
+        LogicalPlan logicalPlan = ((LogicalPlanAdapter) parsedStmt).getLogicalPlan();
+        NereidsPlanner planner = new NereidsPlanner(ctx.getStatementContext());
+        return planner.plan(logicalPlan, PhysicalProperties.ANY, ExplainLevel.NONE);
+    }
+
+    private Set<BaseTableInfo> getOrCreateMTMVs(BaseTableInfo baseTableInfo) {
+        if (!tableMTMVs.containsKey(baseTableInfo)) {
+            tableMTMVs.put(baseTableInfo, Sets.newConcurrentHashSet());
+        }
+        return tableMTMVs.get(baseTableInfo);
+    }
+
+    private void refreshMTMVCache(MTMVRelation relation, BaseTableInfo mtmvInfo) {
+        LOG.info("refreshMTMVCache,relation: {}, mtmvInfo: {}", relation, mtmvInfo);
+        removeMTMV(mtmvInfo);
+        addMTMV(relation, mtmvInfo);
+    }
+
+    private void addMTMV(MTMVRelation relation, BaseTableInfo mtmvInfo) {
+        if (relation == null) {
+            return;
+        }
+        addMTMVTables(relation.getBaseTables(), mtmvInfo);
+        addMTMVTables(relation.getBaseViews(), mtmvInfo);
+    }
+
+    private void addMTMVTables(Set<BaseTableInfo> baseTables, BaseTableInfo mtmvInfo) {
+        if (CollectionUtils.isEmpty(baseTables)) {
+            return;
+        }
+        for (BaseTableInfo baseTableInfo : baseTables) {
+            getOrCreateMTMVs(baseTableInfo).add(mtmvInfo);
+        }
+    }
+
+    private void removeMTMV(BaseTableInfo mtmvInfo) {
+        for (Set<BaseTableInfo> sets : tableMTMVs.values()) {
+            sets.remove(mtmvInfo);
+        }
+    }
+
+    @Override
+    public void createMTMV(MTMV mtmv) throws DdlException {
+
+    }
+
+    @Override
+    public void dropMTMV(MTMV mtmv) throws DdlException {
+
+    }
+
+    /**
+     * modify `tableMTMVs` by MTMVRelation
+     * @param mtmv
+     * @param dbId
+     */
+    @Override
+    public void registerMTMV(MTMV mtmv, Long dbId) {
+        refreshMTMVCache(mtmv.getRelation(), new BaseTableInfo(mtmv.getId(), dbId));
+    }
+
+    /**
+     * remove cache of mtmv
+     * @param mtmv
+     */
+    @Override
+    public void deregisterMTMV(MTMV mtmv) {
+        removeMTMV(new BaseTableInfo(mtmv));
+    }
+
+    @Override
+    public void alterMTMV(MTMV mtmv, AlterMTMV alterMTMV) throws DdlException {
+
+    }
+
+    @Override
+    public void refreshMTMV(RefreshMTMVInfo info) throws DdlException, MetaNotFoundException {
+
+    }
+
+    /**
+     * modify `tableMTMVs` by MTMVRelation
+     * @param mtmv
+     * @param relation
+     * @param task
+     */
+    @Override
+    public void refreshComplete(MTMV mtmv, MTMVRelation relation, MTMVTask task) {
+        if (task.getStatus() == TaskStatus.SUCCESS) {
+            Objects.requireNonNull(relation);
+            refreshMTMVCache(relation, new BaseTableInfo(mtmv));
+        }
+    }
+
+    /**
+     * update mtmv status to `SCHEMA_CHANGE`
+     * @param table
+     */
+    @Override
+    public void dropTable(Table table) {
+        processBaseTableChange(table, "The base table has been deleted:");
+    }
+
+    /**
+     * update mtmv status to `SCHEMA_CHANGE`
+     * @param table
+     */
+    @Override
+    public void alterTable(Table table) {
+        processBaseTableChange(table, "The base table has been updated:");
+    }
+
+    private void processBaseTableChange(Table table, String msgPrefix) {
+        BaseTableInfo baseTableInfo = new BaseTableInfo(table);
+        Set<BaseTableInfo> mtmvsByBaseTable = getMtmvsByBaseTable(baseTableInfo);
+        if (CollectionUtils.isEmpty(mtmvsByBaseTable)) {
+            return;
+        }
+        for (BaseTableInfo mtmvInfo : mtmvsByBaseTable) {
+            Table mtmv = null;
+            try {
+                mtmv = Env.getCurrentEnv().getInternalCatalog()
+                        .getDbOrAnalysisException(mtmvInfo.getDbId())
+                        .getTableOrAnalysisException(mtmvInfo.getTableId());
+            } catch (AnalysisException e) {
+                LOG.warn(e);
+                continue;
+            }
+            TableNameInfo tableNameInfo = new TableNameInfo(mtmv.getQualifiedDbName(),
+                    mtmv.getName());
+            MTMVStatus status = new MTMVStatus(MTMVState.SCHEMA_CHANGE,
+                    msgPrefix + baseTableInfo);
+            Env.getCurrentEnv().alterMTMVStatus(tableNameInfo, status);
+        }
+    }
+}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVHookService.java b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVHookService.java
new file mode 100644
index 00000000000..63ae15fef1b
--- /dev/null
+++ b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVHookService.java
@@ -0,0 +1,104 @@
+// 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.
+
+package org.apache.doris.mtmv;
+
+import org.apache.doris.catalog.MTMV;
+import org.apache.doris.catalog.Table;
+import org.apache.doris.common.DdlException;
+import org.apache.doris.common.MetaNotFoundException;
+import org.apache.doris.job.extensions.mtmv.MTMVTask;
+import org.apache.doris.nereids.trees.plans.commands.info.RefreshMTMVInfo;
+import org.apache.doris.persist.AlterMTMV;
+
+/**
+ * Contains all operations that affect the mtmv
+ */
+public interface MTMVHookService {
+    /**
+     * triggered when create mtmv, only once
+     *
+     * @param mtmv
+     * @throws DdlException
+     */
+    void createMTMV(MTMV mtmv) throws DdlException;
+
+    /**
+     * triggered when drop mtmv, only once
+     *
+     * @param mtmv
+     * @throws DdlException
+     */
+    void dropMTMV(MTMV mtmv) throws DdlException;
+
+    /**
+     * triggered when playing `create mtmv` logs
+     * When triggered, db has not completed playback yet, so use dbId as param
+     *
+     * @param mtmv
+     * @param dbId
+     */
+    void registerMTMV(MTMV mtmv, Long dbId);
+
+    /**
+     * triggered when playing `drop mtmv` logs
+     *
+     * @param mtmv
+     */
+    void deregisterMTMV(MTMV mtmv);
+
+    /**
+     * triggered when alter mtmv, only once
+     *
+     * @param mtmv
+     * @param alterMTMV
+     * @throws DdlException
+     */
+    void alterMTMV(MTMV mtmv, AlterMTMV alterMTMV) throws DdlException;
+
+    /**
+     * triggered when refresh mtmv
+     *
+     * @param info
+     * @throws DdlException
+     * @throws MetaNotFoundException
+     */
+    void refreshMTMV(RefreshMTMVInfo info) throws DdlException, MetaNotFoundException;
+
+    /**
+     * triggered when mtmv task finish
+     *
+     * @param mtmv
+     * @param relation
+     * @param task
+     */
+    void refreshComplete(MTMV mtmv, MTMVRelation relation, MTMVTask task);
+
+    /**
+     * Triggered when baseTable is dropped
+     *
+     * @param table
+     */
+    void dropTable(Table table);
+
+    /**
+     * Triggered when baseTable is altered
+     *
+     * @param table
+     */
+    void alterTable(Table table);
+}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVJobInfo.java b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVJobInfo.java
new file mode 100644
index 00000000000..f253c708e90
--- /dev/null
+++ b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVJobInfo.java
@@ -0,0 +1,63 @@
+// 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.
+
+package org.apache.doris.mtmv;
+
+import org.apache.doris.job.extensions.mtmv.MTMVTask;
+
+import com.google.common.collect.Lists;
+import com.google.gson.annotations.SerializedName;
+
+import java.util.LinkedList;
+
+/**
+ * MTMVJobInfo
+ */
+public class MTMVJobInfo {
+    @SerializedName("jobName")
+    private String jobName;
+    @SerializedName("ht")
+    private LinkedList<MTMVTask> historyTasks;
+
+    public MTMVJobInfo(String jobName) {
+        this.jobName = jobName;
+        historyTasks = Lists.newLinkedList();
+    }
+
+    public String getJobName() {
+        return jobName;
+    }
+
+    public void addHistoryTask(MTMVTask task) {
+        historyTasks.add(task);
+        if (historyTasks.size() > MTMVTask.MAX_HISTORY_TASKS_NUM) {
+            historyTasks.removeFirst();
+        }
+    }
+
+    public LinkedList<MTMVTask> getHistoryTasks() {
+        return historyTasks;
+    }
+
+    @Override
+    public String toString() {
+        return "MTMVJobInfo{"
+                + "jobName='" + jobName + '\''
+                + ", historyTasks=" + historyTasks
+                + '}';
+    }
+}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVJobManager.java b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVJobManager.java
new file mode 100644
index 00000000000..dbd534e47c4
--- /dev/null
+++ b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVJobManager.java
@@ -0,0 +1,195 @@
+// 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.
+
+package org.apache.doris.mtmv;
+
+import org.apache.doris.catalog.Database;
+import org.apache.doris.catalog.Env;
+import org.apache.doris.catalog.MTMV;
+import org.apache.doris.catalog.Table;
+import org.apache.doris.catalog.TableIf.TableType;
+import org.apache.doris.common.DdlException;
+import org.apache.doris.common.MetaNotFoundException;
+import org.apache.doris.common.util.TimeUtils;
+import org.apache.doris.job.base.JobExecuteType;
+import org.apache.doris.job.base.JobExecutionConfiguration;
+import org.apache.doris.job.base.TimerDefinition;
+import org.apache.doris.job.common.JobStatus;
+import org.apache.doris.job.common.JobType;
+import org.apache.doris.job.exception.JobException;
+import org.apache.doris.job.extensions.mtmv.MTMVJob;
+import org.apache.doris.job.extensions.mtmv.MTMVTask;
+import org.apache.doris.mtmv.MTMVRefreshEnum.BuildMode;
+import org.apache.doris.mtmv.MTMVRefreshEnum.RefreshTrigger;
+import org.apache.doris.nereids.trees.plans.commands.info.RefreshMTMVInfo;
+import org.apache.doris.persist.AlterMTMV;
+import org.apache.doris.qe.ConnectContext;
+
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.List;
+
+/**
+ * when do some operation, do something about job
+ */
+public class MTMVJobManager implements MTMVHookService {
+    public static final String MTMV_JOB_PREFIX = "mtmv_";
+
+    /**
+     * create MTMVJob
+     * @param mtmv
+     * @throws DdlException
+     */
+    @Override
+    public void createMTMV(MTMV mtmv) throws DdlException {
+        MTMVJob job = new MTMVJob(mtmv.getDatabase().getId(), mtmv.getId());
+        job.setJobId(Env.getCurrentEnv().getNextId());
+        job.setJobName(mtmv.getJobInfo().getJobName());
+        job.setComment(mtmv.getName());
+        job.setCreateUser(ConnectContext.get().getCurrentUserIdentity());
+        job.setJobStatus(JobStatus.RUNNING);
+        job.setJobConfig(getJobConfig(mtmv));
+        try {
+            Env.getCurrentEnv().getJobManager().registerJob(job);
+        } catch (JobException e) {
+            throw new DdlException(e.getMessage(), e);
+        }
+    }
+
+    private JobExecutionConfiguration getJobConfig(MTMV mtmv) {
+        JobExecutionConfiguration jobExecutionConfiguration = new JobExecutionConfiguration();
+        if (mtmv.getRefreshInfo().getRefreshTriggerInfo().getRefreshTrigger()
+                .equals(RefreshTrigger.SCHEDULE)) {
+            setScheduleJobConfig(jobExecutionConfiguration, mtmv);
+        } else if (mtmv.getRefreshInfo().getRefreshTriggerInfo().getRefreshTrigger()
+                .equals(RefreshTrigger.MANUAL)) {
+            setManualJobConfig(jobExecutionConfiguration, mtmv);
+        }
+        return jobExecutionConfiguration;
+    }
+
+    private void setManualJobConfig(JobExecutionConfiguration jobExecutionConfiguration, MTMV mtmv) {
+        jobExecutionConfiguration.setExecuteType(JobExecuteType.MANUAL);
+        if (mtmv.getRefreshInfo().getBuildMode().equals(BuildMode.IMMEDIATE)) {
+            jobExecutionConfiguration.setImmediate(true);
+        } else {
+            jobExecutionConfiguration.setImmediate(false);
+        }
+    }
+
+    private void setScheduleJobConfig(JobExecutionConfiguration jobExecutionConfiguration, MTMV mtmv) {
+        jobExecutionConfiguration.setExecuteType(JobExecuteType.RECURRING);
+        TimerDefinition timerDefinition = new TimerDefinition();
+        timerDefinition
+                .setInterval(mtmv.getRefreshInfo().getRefreshTriggerInfo().getIntervalTrigger().getInterval());
+        timerDefinition
+                .setIntervalUnit(mtmv.getRefreshInfo().getRefreshTriggerInfo().getIntervalTrigger().getTimeUnit());
+        if (mtmv.getRefreshInfo().getBuildMode().equals(BuildMode.IMMEDIATE)) {
+            jobExecutionConfiguration.setImmediate(true);
+        } else if (mtmv.getRefreshInfo().getBuildMode().equals(BuildMode.DEFERRED) && !StringUtils
+                .isEmpty(mtmv.getRefreshInfo().getRefreshTriggerInfo().getIntervalTrigger().getStartTime())) {
+            timerDefinition.setStartTimeMs(TimeUtils.timeStringToLong(
+                    mtmv.getRefreshInfo().getRefreshTriggerInfo().getIntervalTrigger().getStartTime()));
+        }
+
+        jobExecutionConfiguration.setTimerDefinition(timerDefinition);
+    }
+
+    /**
+     * drop MTMVJob
+     * @param mtmv
+     * @throws DdlException
+     */
+    @Override
+    public void dropMTMV(MTMV mtmv) throws DdlException {
+        List<MTMVJob> jobs = Env.getCurrentEnv().getJobManager()
+                .queryJobs(JobType.MTMV, mtmv.getJobInfo().getJobName());
+        if (!CollectionUtils.isEmpty(jobs)) {
+            try {
+                Env.getCurrentEnv().getJobManager()
+                        .unregisterJob(jobs.get(0).getJobId());
+            } catch (JobException e) {
+                e.printStackTrace();
+                throw new DdlException(e.getMessage());
+            }
+        }
+    }
+
+    @Override
+    public void registerMTMV(MTMV mtmv, Long dbId) {
+
+    }
+
+    @Override
+    public void deregisterMTMV(MTMV mtmv) {
+
+    }
+
+    /**
+     * drop MTMVJob and then create MTMVJob
+     * @param mtmv
+     * @param alterMTMV
+     * @throws DdlException
+     */
+    @Override
+    public void alterMTMV(MTMV mtmv, AlterMTMV alterMTMV) throws DdlException {
+        if (alterMTMV.isNeedRebuildJob()) {
+            dropMTMV(mtmv);
+            createMTMV(mtmv);
+        }
+    }
+
+    /**
+     * trigger MTMVJob
+     * @param info
+     * @throws DdlException
+     * @throws MetaNotFoundException
+     */
+    @Override
+    public void refreshMTMV(RefreshMTMVInfo info) throws DdlException, MetaNotFoundException {
+        Database db = Env.getCurrentInternalCatalog().getDbOrDdlException(info.getMvName().getDb());
+        MTMV mtmv = (MTMV) db.getTableOrMetaException(info.getMvName().getTbl(), TableType.MATERIALIZED_VIEW);
+        List<MTMVJob> jobs = Env.getCurrentEnv().getJobManager()
+                .queryJobs(JobType.MTMV, mtmv.getJobInfo().getJobName());
+        if (CollectionUtils.isEmpty(jobs) || jobs.size() != 1) {
+            throw new DdlException("jobs not normal,should have one job,but job num is: " + jobs.size());
+        }
+        try {
+            Env.getCurrentEnv().getJobManager().triggerJob(jobs.get(0).getJobId());
+        } catch (JobException e) {
+            e.printStackTrace();
+            throw new DdlException(e.getMessage());
+        }
+    }
+
+    @Override
+    public void refreshComplete(MTMV mtmv, MTMVRelation relation, MTMVTask task) {
+
+    }
+
+    @Override
+    public void dropTable(Table table) {
+
+    }
+
+    @Override
+    public void alterTable(Table table) {
+
+    }
+
+}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVRefreshEnum.java b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVRefreshEnum.java
index 6f14a2ba014..ed2f0f709f4 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVRefreshEnum.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVRefreshEnum.java
@@ -59,7 +59,6 @@ public class MTMVRefreshEnum {
      */
     public enum MTMVRefreshState {
         INIT,
-        REFRESHING,
         FAIL,
         SUCCESS
     }
diff --git a/fe/fe-core/src/main/java/org/apache/doris/mtmv/EnvInfo.java b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVRelation.java
similarity index 50%
copy from fe/fe-core/src/main/java/org/apache/doris/mtmv/EnvInfo.java
copy to fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVRelation.java
index c5c92a15db9..d8f4d5be627 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/mtmv/EnvInfo.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVRelation.java
@@ -19,25 +19,36 @@ package org.apache.doris.mtmv;
 
 import com.google.gson.annotations.SerializedName;
 
-/**
- * EnvInfo
- */
-public class EnvInfo {
-    @SerializedName("cn")
-    private String ctlName;
-    @SerializedName("dn")
-    private String dbName;
-
-    public EnvInfo(String ctlName, String dbName) {
-        this.ctlName = ctlName;
-        this.dbName = dbName;
+import java.util.Set;
+
+public class MTMVRelation {
+    // if mtmv query sql is `select * from view1`;
+    // and `view1` query sql is `select * from table1 join table2`
+    // then baseTables will include: `table1` and `table2`
+    // baseViews will include `view1`
+    @SerializedName("bt")
+    private Set<BaseTableInfo> baseTables;
+    @SerializedName("bv")
+    private Set<BaseTableInfo> baseViews;
+
+    public MTMVRelation(Set<BaseTableInfo> baseTables, Set<BaseTableInfo> baseViews) {
+        this.baseTables = baseTables;
+        this.baseViews = baseViews;
+    }
+
+    public Set<BaseTableInfo> getBaseTables() {
+        return baseTables;
     }
 
-    public String getCtlName() {
-        return ctlName;
+    public Set<BaseTableInfo> getBaseViews() {
+        return baseViews;
     }
 
-    public String getDbName() {
-        return dbName;
+    @Override
+    public String toString() {
+        return "MTMVRelation{"
+                + "baseTables=" + baseTables
+                + ", baseViews=" + baseViews
+                + '}';
     }
 }
diff --git a/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVService.java b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVService.java
new file mode 100644
index 00000000000..e83ca4e9496
--- /dev/null
+++ b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVService.java
@@ -0,0 +1,136 @@
+// 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.
+
+package org.apache.doris.mtmv;
+
+import org.apache.doris.catalog.MTMV;
+import org.apache.doris.catalog.Table;
+import org.apache.doris.common.DdlException;
+import org.apache.doris.common.MetaNotFoundException;
+import org.apache.doris.job.extensions.mtmv.MTMVTask;
+import org.apache.doris.nereids.trees.plans.commands.info.RefreshMTMVInfo;
+import org.apache.doris.persist.AlterMTMV;
+
+import com.google.common.collect.Maps;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import java.util.Map;
+import java.util.Objects;
+
+public class MTMVService {
+    private static final Logger LOG = LogManager.getLogger(MTMVService.class);
+
+    private Map<String, MTMVHookService> hooks = Maps.newConcurrentMap();
+    private MTMVCacheManager cacheManager = new MTMVCacheManager();
+    private MTMVJobManager jobManager = new MTMVJobManager();
+
+    public MTMVService() {
+        registerHook("MTMVJobManager", jobManager);
+        registerHook("MTMVCacheManager", cacheManager);
+    }
+
+    public MTMVCacheManager getCacheManager() {
+        return cacheManager;
+    }
+
+    public void registerHook(String name, MTMVHookService mtmvHookService) {
+        Objects.requireNonNull(name);
+        Objects.requireNonNull(mtmvHookService);
+        hooks.put(name, mtmvHookService);
+        LOG.info("registerHook: " + name);
+    }
+
+    public void deregisterHook(String name) {
+        hooks.remove(name);
+        LOG.info("deregisterHook: " + name);
+    }
+
+    public void registerMTMV(MTMV mtmv, Long dbId) {
+        Objects.requireNonNull(mtmv);
+        LOG.info("registerMTMV: " + mtmv.getName());
+        for (MTMVHookService mtmvHookService : hooks.values()) {
+            mtmvHookService.registerMTMV(mtmv, dbId);
+        }
+    }
+
+    public void deregisterMTMV(MTMV mtmv) {
+        Objects.requireNonNull(mtmv);
+        LOG.info("deregisterMTMV: " + mtmv.getName());
+        for (MTMVHookService mtmvHookService : hooks.values()) {
+            mtmvHookService.deregisterMTMV(mtmv);
+        }
+    }
+
+    public void createMTMV(MTMV mtmv) throws DdlException {
+        Objects.requireNonNull(mtmv);
+        LOG.info("createMTMV: " + mtmv.getName());
+        for (MTMVHookService mtmvHookService : hooks.values()) {
+            mtmvHookService.createMTMV(mtmv);
+        }
+    }
+
+    public void dropMTMV(MTMV mtmv) throws DdlException {
+        Objects.requireNonNull(mtmv);
+        LOG.info("dropMTMV: " + mtmv.getName());
+        for (MTMVHookService mtmvHookService : hooks.values()) {
+            mtmvHookService.dropMTMV(mtmv);
+        }
+    }
+
+    public void alterMTMV(MTMV mtmv, AlterMTMV alterMTMV) throws DdlException {
+        Objects.requireNonNull(mtmv);
+        Objects.requireNonNull(alterMTMV);
+        LOG.info("alterMTMV, mtmvName: {}, AlterMTMV: {}", mtmv.getName(), alterMTMV);
+        for (MTMVHookService mtmvHookService : hooks.values()) {
+            mtmvHookService.alterMTMV(mtmv, alterMTMV);
+        }
+    }
+
+    public void refreshMTMV(RefreshMTMVInfo info) throws DdlException, MetaNotFoundException {
+        Objects.requireNonNull(info);
+        LOG.info("refreshMTMV, RefreshMTMVInfo: {}", info);
+        for (MTMVHookService mtmvHookService : hooks.values()) {
+            mtmvHookService.refreshMTMV(info);
+        }
+    }
+
+    public void dropTable(Table table) {
+        Objects.requireNonNull(table);
+        LOG.info("dropTable, tableName: {}", table.getName());
+        for (MTMVHookService mtmvHookService : hooks.values()) {
+            mtmvHookService.dropTable(table);
+        }
+    }
+
+    public void alterTable(Table table) {
+        Objects.requireNonNull(table);
+        LOG.info("alterTable, tableName: {}", table.getName());
+        for (MTMVHookService mtmvHookService : hooks.values()) {
+            mtmvHookService.alterTable(table);
+        }
+    }
+
+    public void refreshComplete(MTMV mtmv, MTMVRelation cache, MTMVTask task) {
+        Objects.requireNonNull(mtmv);
+        Objects.requireNonNull(task);
+        LOG.info("refreshComplete: " + mtmv.getName());
+        for (MTMVHookService mtmvHookService : hooks.values()) {
+            mtmvHookService.refreshComplete(mtmv, cache, task);
+        }
+    }
+}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVStatus.java b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVStatus.java
new file mode 100644
index 00000000000..ea05dbc8673
--- /dev/null
+++ b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVStatus.java
@@ -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.
+
+package org.apache.doris.mtmv;
+
+import org.apache.doris.mtmv.MTMVRefreshEnum.MTMVRefreshState;
+import org.apache.doris.mtmv.MTMVRefreshEnum.MTMVState;
+
+import com.google.gson.annotations.SerializedName;
+
+import java.util.Objects;
+
+public class MTMVStatus {
+    @SerializedName("state")
+    private MTMVState state;
+    @SerializedName("schemaChangeDetail")
+    private String schemaChangeDetail;
+    @SerializedName("refreshState")
+    private MTMVRefreshState refreshState;
+
+    public MTMVStatus() {
+        this.state = MTMVState.INIT;
+        this.refreshState = MTMVRefreshState.INIT;
+    }
+
+    public MTMVStatus(MTMVState state, String schemaChangeDetail) {
+        this.state = state;
+        this.schemaChangeDetail = schemaChangeDetail;
+    }
+
+    public MTMVStatus(MTMVRefreshState refreshState) {
+        this.refreshState = refreshState;
+    }
+
+    public MTMVState getState() {
+        return state;
+    }
+
+    public String getSchemaChangeDetail() {
+        return schemaChangeDetail;
+    }
+
+    public MTMVRefreshState getRefreshState() {
+        return refreshState;
+    }
+
+    public void setState(MTMVState state) {
+        this.state = state;
+    }
+
+    public void setSchemaChangeDetail(String schemaChangeDetail) {
+        this.schemaChangeDetail = schemaChangeDetail;
+    }
+
+    public void setRefreshState(MTMVRefreshState refreshState) {
+        this.refreshState = refreshState;
+    }
+
+    public MTMVStatus updateNotNull(MTMVStatus status) {
+        Objects.requireNonNull(status);
+        if (status.getState() != null) {
+            this.state = status.getState();
+            if (this.state == MTMVState.SCHEMA_CHANGE) {
+                this.schemaChangeDetail = status.getSchemaChangeDetail();
+            } else {
+                this.schemaChangeDetail = null;
+            }
+        }
+        if (status.getRefreshState() != null) {
+            this.refreshState = status.getRefreshState();
+        }
+        return this;
+    }
+
+    @Override
+    public String toString() {
+        return "MTMVStatus{"
+                + "state=" + state
+                + ", schemaChangeDetail='" + schemaChangeDetail + '\''
+                + ", refreshState=" + refreshState
+                + '}';
+    }
+}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/CreateMTMVCommand.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/CreateMTMVCommand.java
index 76a646fc819..c246991e618 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/CreateMTMVCommand.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/CreateMTMVCommand.java
@@ -17,7 +17,7 @@
 
 package org.apache.doris.nereids.trees.plans.commands;
 
-import org.apache.doris.nereids.exceptions.AnalysisException;
+import org.apache.doris.catalog.Env;
 import org.apache.doris.nereids.trees.plans.PlanType;
 import org.apache.doris.nereids.trees.plans.commands.info.CreateMTMVInfo;
 import org.apache.doris.nereids.trees.plans.visitor.PlanVisitor;
@@ -48,7 +48,7 @@ public class CreateMTMVCommand extends Command implements ForwardWithSync {
     @Override
     public void run(ConnectContext ctx, StmtExecutor executor) throws Exception {
         createMTMVInfo.analyze(ctx);
-        throw new AnalysisException("current not support.");
+        Env.getCurrentEnv().createTable(createMTMVInfo.translateToLegacyStmt());
     }
 
     @Override
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/DropMTMVCommand.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/DropMTMVCommand.java
index 0a6494edeac..a0d614b163c 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/DropMTMVCommand.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/DropMTMVCommand.java
@@ -17,7 +17,7 @@
 
 package org.apache.doris.nereids.trees.plans.commands;
 
-import org.apache.doris.nereids.exceptions.AnalysisException;
+import org.apache.doris.catalog.Env;
 import org.apache.doris.nereids.trees.plans.PlanType;
 import org.apache.doris.nereids.trees.plans.commands.info.DropMTMVInfo;
 import org.apache.doris.nereids.trees.plans.visitor.PlanVisitor;
@@ -40,7 +40,7 @@ public class DropMTMVCommand extends Command implements ForwardWithSync {
     @Override
     public void run(ConnectContext ctx, StmtExecutor executor) throws Exception {
         dropMTMVInfo.analyze(ctx);
-        throw new AnalysisException("current not support.");
+        Env.getCurrentEnv().dropTable(dropMTMVInfo.translateToLegacyStmt());
     }
 
     @Override
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/InsertIntoTableCommand.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/InsertIntoTableCommand.java
index 45411204524..ceb2ad9270a 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/InsertIntoTableCommand.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/InsertIntoTableCommand.java
@@ -66,6 +66,7 @@ import org.apache.doris.transaction.TransactionStatus;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Strings;
 import com.google.common.collect.Lists;
+import lombok.Setter;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
@@ -95,11 +96,19 @@ public class InsertIntoTableCommand extends Command implements ForwardWithSync,
     public static final Logger LOG = LogManager.getLogger(InsertIntoTableCommand.class);
 
     private final LogicalPlan logicalQuery;
-    private final Optional<String> labelName;
+
+    @Setter
+    private Optional<String> labelName;
     private final boolean isOverwrite;
     private NereidsPlanner planner;
     private boolean isTxnBegin = false;
 
+    /**
+     * When source it's from job scheduler,it will be set.
+     */
+    @Setter
+    private long jobId;
+
     /**
      * constructor
      */
@@ -204,7 +213,7 @@ public class InsertIntoTableCommand extends Command implements ForwardWithSync,
         LOG.info("Nereids start to execute the insert command, query id: {}, txn id: {}",
                 ctx.queryId(), txn.getTxnId());
 
-        txn.executeInsertIntoTableCommand(executor);
+        txn.executeInsertIntoTableCommand(executor, jobId);
         if (ctx.getState().getStateType() == MysqlStateType.ERR) {
             try {
                 String errMsg = Strings.emptyToNull(ctx.getState().getErrorMessage());
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/RefreshMTMVCommand.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/RefreshMTMVCommand.java
index 352801f5d83..982e8d86257 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/RefreshMTMVCommand.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/RefreshMTMVCommand.java
@@ -17,7 +17,7 @@
 
 package org.apache.doris.nereids.trees.plans.commands;
 
-import org.apache.doris.nereids.exceptions.AnalysisException;
+import org.apache.doris.catalog.Env;
 import org.apache.doris.nereids.trees.plans.PlanType;
 import org.apache.doris.nereids.trees.plans.commands.info.RefreshMTMVInfo;
 import org.apache.doris.nereids.trees.plans.visitor.PlanVisitor;
@@ -40,7 +40,7 @@ public class RefreshMTMVCommand extends Command implements ForwardWithSync {
     @Override
     public void run(ConnectContext ctx, StmtExecutor executor) throws Exception {
         refreshMTMVInfo.analyze(ctx);
-        throw new AnalysisException("current not support.");
+        Env.getCurrentEnv().getMtmvService().refreshMTMV(refreshMTMVInfo);
     }
 
     @Override
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/AlterMTMVPropertyInfo.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/AlterMTMVPropertyInfo.java
index a7ddfb8f83c..5f9be47fc70 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/AlterMTMVPropertyInfo.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/AlterMTMVPropertyInfo.java
@@ -17,7 +17,9 @@
 
 package org.apache.doris.nereids.trees.plans.commands.info;
 
+import org.apache.doris.catalog.Env;
 import org.apache.doris.common.UserException;
+import org.apache.doris.common.util.PropertyAnalyzer;
 import org.apache.doris.nereids.exceptions.AnalysisException;
 import org.apache.doris.qe.ConnectContext;
 
@@ -40,11 +42,29 @@ public class AlterMTMVPropertyInfo extends AlterMTMVInfo {
 
     public void analyze(ConnectContext ctx) throws AnalysisException {
         super.analyze(ctx);
+        analyzeProperties();
     }
 
     @Override
     public void run() throws UserException {
-        throw new org.apache.doris.nereids.exceptions.AnalysisException("current not support.");
+        Env.getCurrentEnv().alterMTMVProperty(this);
+    }
+
+    private void analyzeProperties() {
+        for (String key : properties.keySet()) {
+            if (PropertyAnalyzer.PROPERTIES_GRACE_PERIOD.equals(key)) {
+                String gracePeriod = properties.get(PropertyAnalyzer.PROPERTIES_GRACE_PERIOD);
+                try {
+                    Long.parseLong(gracePeriod);
+                } catch (NumberFormatException e) {
+                    throw new org.apache.doris.nereids.exceptions.AnalysisException(
+                            "valid grace_period: " + properties.get(PropertyAnalyzer.PROPERTIES_GRACE_PERIOD));
+                }
+            } else {
+                throw new org.apache.doris.nereids.exceptions.AnalysisException("illegal key:" + key);
+            }
+        }
+
     }
 
     public Map<String, String> getProperties() {
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/AlterMTMVRefreshInfo.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/AlterMTMVRefreshInfo.java
index b54bba1ece3..25bb78f2fc2 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/AlterMTMVRefreshInfo.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/AlterMTMVRefreshInfo.java
@@ -17,6 +17,7 @@
 
 package org.apache.doris.nereids.trees.plans.commands.info;
 
+import org.apache.doris.catalog.Env;
 import org.apache.doris.common.UserException;
 import org.apache.doris.mtmv.MTMVRefreshInfo;
 import org.apache.doris.nereids.exceptions.AnalysisException;
@@ -45,7 +46,7 @@ public class AlterMTMVRefreshInfo extends AlterMTMVInfo {
 
     @Override
     public void run() throws UserException {
-        throw new AnalysisException("current not support.");
+        Env.getCurrentEnv().alterMTMVRefreshInfo(this);
     }
 
     public MTMVRefreshInfo getRefreshInfo() {
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/AlterMTMVRenameInfo.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/AlterMTMVRenameInfo.java
index c9e09e29187..a93c53087d3 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/AlterMTMVRenameInfo.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/AlterMTMVRenameInfo.java
@@ -17,6 +17,9 @@
 
 package org.apache.doris.nereids.trees.plans.commands.info;
 
+import org.apache.doris.catalog.Database;
+import org.apache.doris.catalog.Env;
+import org.apache.doris.catalog.Table;
 import org.apache.doris.common.DdlException;
 import org.apache.doris.common.FeNameFormat;
 import org.apache.doris.nereids.exceptions.AnalysisException;
@@ -40,6 +43,7 @@ public class AlterMTMVRenameInfo extends AlterMTMVInfo {
 
     /**
      * analyze
+     *
      * @param ctx ctx
      * @throws AnalysisException AnalysisException
      */
@@ -54,6 +58,8 @@ public class AlterMTMVRenameInfo extends AlterMTMVInfo {
 
     @Override
     public void run() throws DdlException {
-        throw new AnalysisException("current not support.");
+        Database db = Env.getCurrentInternalCatalog().getDbOrDdlException(mvName.getDb());
+        Table table = db.getTableOrDdlException(mvName.getTbl());
+        Env.getCurrentEnv().renameTable(db, table, newName);
     }
 }
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/ColumnDefinition.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/ColumnDefinition.java
index 8b2a8df338d..9a3c92dcfb6 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/ColumnDefinition.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/ColumnDefinition.java
@@ -102,6 +102,10 @@ public class ColumnDefinition {
         this(name, type, false, null, isNullable, Optional.empty(), "");
     }
 
+    public ColumnDefinition(String name, DataType type, boolean isNullable, String comment) {
+        this(name, type, false, null, isNullable, Optional.empty(), comment);
+    }
+
     public String getName() {
         return name;
     }
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/CreateMTMVInfo.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/CreateMTMVInfo.java
index 1b255adc528..98e610aab9e 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/CreateMTMVInfo.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/CreateMTMVInfo.java
@@ -17,18 +17,48 @@
 
 package org.apache.doris.nereids.trees.plans.commands.info;
 
+import org.apache.doris.analysis.CreateMTMVStmt;
+import org.apache.doris.analysis.KeysDesc;
+import org.apache.doris.analysis.TableName;
+import org.apache.doris.catalog.Column;
+import org.apache.doris.catalog.Env;
+import org.apache.doris.catalog.KeysType;
+import org.apache.doris.catalog.TableIf;
+import org.apache.doris.catalog.TableIf.TableType;
+import org.apache.doris.common.ErrorCode;
+import org.apache.doris.common.FeNameFormat;
+import org.apache.doris.common.util.PropertyAnalyzer;
 import org.apache.doris.mtmv.EnvInfo;
 import org.apache.doris.mtmv.MTMVRefreshInfo;
+import org.apache.doris.mysql.privilege.PrivPredicate;
+import org.apache.doris.nereids.NereidsPlanner;
+import org.apache.doris.nereids.exceptions.AnalysisException;
+import org.apache.doris.nereids.properties.PhysicalProperties;
+import org.apache.doris.nereids.trees.TreeNode;
+import org.apache.doris.nereids.trees.expressions.Expression;
+import org.apache.doris.nereids.trees.expressions.Slot;
+import org.apache.doris.nereids.trees.plans.Plan;
+import org.apache.doris.nereids.trees.plans.commands.ExplainCommand.ExplainLevel;
 import org.apache.doris.nereids.trees.plans.logical.LogicalPlan;
+import org.apache.doris.nereids.trees.plans.physical.PhysicalPlan;
+import org.apache.doris.nereids.trees.plans.visitor.NondeterministicFunctionCollector;
+import org.apache.doris.nereids.trees.plans.visitor.TableCollector;
+import org.apache.doris.nereids.trees.plans.visitor.TableCollector.TableCollectorContext;
 import org.apache.doris.nereids.util.Utils;
 import org.apache.doris.qe.ConnectContext;
 
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+import org.apache.commons.collections.CollectionUtils;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.stream.Collectors;
 
 /**
  * MTMV info in creating MTMV.
@@ -69,14 +99,133 @@ public class CreateMTMVInfo {
         this.refreshInfo = Objects.requireNonNull(refreshInfo, "require refreshInfo object");
         this.simpleColumnDefinitions = Objects
                 .requireNonNull(simpleColumnDefinitions, "require simpleColumnDefinitions object");
-        this.envInfo = new EnvInfo(ConnectContext.get().getDefaultCatalog(), ConnectContext.get().getDatabase());
+        this.envInfo = new EnvInfo(ConnectContext.get().getCurrentCatalog().getId(),
+                ConnectContext.get().getCurrentDbId());
     }
 
     /**
      * analyze create table info
      */
     public void analyze(ConnectContext ctx) {
+        // analyze table name
+        mvName.analyze(ctx);
+        if (!Env.getCurrentEnv().getAccessManager().checkTblPriv(ConnectContext.get(), mvName.getDb(),
+                mvName.getTbl(), PrivPredicate.CREATE)) {
+            String message = ErrorCode.ERR_TABLEACCESS_DENIED_ERROR.formatErrorMsg("CREATE",
+                    ConnectContext.get().getQualifiedUser(), ConnectContext.get().getRemoteIP(),
+                    mvName.getDb() + ": " + mvName.getTbl());
+            throw new AnalysisException(message);
+        }
+        analyzeProperties();
+        analyzeQuery(ctx);
+        // analyze column
+        final boolean finalEnableMergeOnWrite = false;
+        Set<String> keysSet = Sets.newTreeSet(String.CASE_INSENSITIVE_ORDER);
+        keysSet.addAll(keys);
+        columns.forEach(c -> c.validate(keysSet, finalEnableMergeOnWrite, KeysType.DUP_KEYS));
 
+        if (distribution == null) {
+            throw new AnalysisException("Create MTMV should contain distribution desc");
+        }
+
+        if (properties == null) {
+            properties = Maps.newHashMap();
+        }
+
+        // analyze distribute
+        Map<String, ColumnDefinition> columnMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
+        columns.forEach(c -> columnMap.put(c.getName(), c));
+        distribution.updateCols(columns.get(0).getName());
+        distribution.validate(columnMap, KeysType.DUP_KEYS);
+        refreshInfo.validate();
+
+        analyzeProperties();
+    }
+
+    private void analyzeProperties() {
+        if (properties.containsKey(PropertyAnalyzer.PROPERTIES_GRACE_PERIOD)) {
+            String gracePeriod = properties.get(PropertyAnalyzer.PROPERTIES_GRACE_PERIOD);
+            try {
+                Long.parseLong(gracePeriod);
+            } catch (NumberFormatException e) {
+                throw new AnalysisException(
+                        "valid grace_period: " + properties.get(PropertyAnalyzer.PROPERTIES_GRACE_PERIOD));
+            }
+            mvProperties.put(PropertyAnalyzer.PROPERTIES_GRACE_PERIOD, gracePeriod);
+            properties.remove(PropertyAnalyzer.PROPERTIES_GRACE_PERIOD);
+        }
+    }
+
+    /**
+     * analyzeQuery
+     */
+    public void analyzeQuery(ConnectContext ctx) {
+        // create table as select
+        NereidsPlanner planner = new NereidsPlanner(ctx.getStatementContext());
+        Plan plan = planner.plan(logicalQuery, PhysicalProperties.ANY, ExplainLevel.ALL_PLAN);
+        analyzeBaseTables(plan);
+        analyzeExpressions((PhysicalPlan) plan);
+        getColumns(plan);
+    }
+
+    private void analyzeBaseTables(Plan plan) {
+        TableCollectorContext collectorContext =
+                new TableCollector.TableCollectorContext(Sets.newHashSet(TableType.MATERIALIZED_VIEW));
+        plan.accept(TableCollector.INSTANCE, collectorContext);
+        List<TableIf> collectedTables = collectorContext.getCollectedTables();
+        if (!CollectionUtils.isEmpty(collectedTables)) {
+            throw new AnalysisException("can not contain MATERIALIZED_VIEW");
+        }
+    }
+
+    private void analyzeExpressions(PhysicalPlan plan) {
+        List<TreeNode<Expression>> functionCollectResult = new ArrayList<>();
+        plan.accept(NondeterministicFunctionCollector.INSTANCE, functionCollectResult);
+        if (!CollectionUtils.isEmpty(functionCollectResult)) {
+            throw new AnalysisException("can not contain invalid expression");
+        }
+    }
+
+    private void getColumns(Plan plan) {
+        List<Slot> slots = plan.getOutput();
+        if (slots.isEmpty()) {
+            throw new AnalysisException("table should contain at least one column");
+        }
+        if (!CollectionUtils.isEmpty(simpleColumnDefinitions) && simpleColumnDefinitions.size() != slots.size()) {
+            throw new AnalysisException("simpleColumnDefinitions size is not equal to the query's");
+        }
+        Set<String> colNames = Sets.newHashSet();
+        for (int i = 0; i < slots.size(); i++) {
+            String colName = CollectionUtils.isEmpty(simpleColumnDefinitions) ? slots.get(i).getName()
+                    : simpleColumnDefinitions.get(i).getName();
+            try {
+                FeNameFormat.checkColumnName(colName);
+            } catch (org.apache.doris.common.AnalysisException e) {
+                throw new AnalysisException(e.getMessage());
+            }
+            if (colNames.contains(colName)) {
+                throw new AnalysisException("repeat cols:" + colName);
+            } else {
+                colNames.add(colName);
+            }
+            columns.add(new ColumnDefinition(
+                    colName, slots.get(i).getDataType(), true,
+                    CollectionUtils.isEmpty(simpleColumnDefinitions) ? null
+                            : simpleColumnDefinitions.get(i).getComment()));
+        }
+    }
+
+    /**
+     * translate to catalog CreateMultiTableMaterializedViewStmt
+     */
+    public CreateMTMVStmt translateToLegacyStmt() {
+        TableName tableName = mvName.transferToTableName();
+        KeysDesc keysDesc = new KeysDesc(KeysType.DUP_KEYS, keys);
+        List<Column> catalogColumns = columns.stream()
+                .map(ColumnDefinition::translateToCatalogStyle)
+                .collect(Collectors.toList());
+        return new CreateMTMVStmt(ifNotExists, tableName, catalogColumns, refreshInfo, keysDesc,
+                distribution.translateToCatalogStyle(), properties, mvProperties, querySql, comment, envInfo);
     }
 
 }
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/DropMTMVInfo.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/DropMTMVInfo.java
index 958d6315c39..650df2c96c3 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/DropMTMVInfo.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/DropMTMVInfo.java
@@ -17,6 +17,12 @@
 
 package org.apache.doris.nereids.trees.plans.commands.info;
 
+import org.apache.doris.analysis.DropTableStmt;
+import org.apache.doris.analysis.TableName;
+import org.apache.doris.catalog.Env;
+import org.apache.doris.common.ErrorCode;
+import org.apache.doris.mysql.privilege.PrivPredicate;
+import org.apache.doris.nereids.exceptions.AnalysisException;
 import org.apache.doris.qe.ConnectContext;
 
 import java.util.Objects;
@@ -39,6 +45,14 @@ public class DropMTMVInfo {
      * @param ctx ConnectContext
      */
     public void analyze(ConnectContext ctx) {
+        mvName.analyze(ctx);
+        if (!Env.getCurrentEnv().getAccessManager().checkTblPriv(ConnectContext.get(), mvName.getDb(),
+                mvName.getTbl(), PrivPredicate.DROP)) {
+            String message = ErrorCode.ERR_TABLEACCESS_DENIED_ERROR.formatErrorMsg("DROP",
+                    ConnectContext.get().getQualifiedUser(), ConnectContext.get().getRemoteIP(),
+                    mvName.getDb() + ": " + mvName.getTbl());
+            throw new AnalysisException(message);
+        }
     }
 
     /**
@@ -49,4 +63,14 @@ public class DropMTMVInfo {
     public TableNameInfo getMvName() {
         return mvName;
     }
+
+    /**
+     * translate to catalog DropTableStmt
+     */
+    public DropTableStmt translateToLegacyStmt() {
+        TableName tableName = mvName.transferToTableName();
+        DropTableStmt dropTableStmt = new DropTableStmt(ifExists, tableName, false);
+        dropTableStmt.setMaterializedView(true);
+        return dropTableStmt;
+    }
 }
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/RefreshMTMVInfo.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/RefreshMTMVInfo.java
index 8439ed2ad0a..422b9697c7c 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/RefreshMTMVInfo.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/RefreshMTMVInfo.java
@@ -17,6 +17,10 @@
 
 package org.apache.doris.nereids.trees.plans.commands.info;
 
+import org.apache.doris.catalog.Env;
+import org.apache.doris.common.ErrorCode;
+import org.apache.doris.mysql.privilege.PrivPredicate;
+import org.apache.doris.nereids.exceptions.AnalysisException;
 import org.apache.doris.qe.ConnectContext;
 
 import java.util.Objects;
@@ -36,6 +40,14 @@ public class RefreshMTMVInfo {
      * @param ctx ConnectContext
      */
     public void analyze(ConnectContext ctx) {
+        mvName.analyze(ctx);
+        if (!Env.getCurrentEnv().getAccessManager().checkTblPriv(ConnectContext.get(), mvName.getDb(),
+                mvName.getTbl(), PrivPredicate.CREATE)) {
+            String message = ErrorCode.ERR_TABLEACCESS_DENIED_ERROR.formatErrorMsg("CREATE",
+                    ConnectContext.get().getQualifiedUser(), ConnectContext.get().getRemoteIP(),
+                    mvName.getDb() + ": " + mvName.getTbl());
+            throw new AnalysisException(message);
+        }
     }
 
     /**
diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/txn/Transaction.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/txn/Transaction.java
index 48f80ad907a..9e8663fa1a7 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/txn/Transaction.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/txn/Transaction.java
@@ -18,6 +18,7 @@
 package org.apache.doris.nereids.txn;
 
 import org.apache.doris.analysis.StatementBase;
+import org.apache.doris.analysis.UserIdentity;
 import org.apache.doris.catalog.Database;
 import org.apache.doris.catalog.Env;
 import org.apache.doris.catalog.Table;
@@ -92,7 +93,7 @@ public class Transaction {
     /**
      * execute insert txn for insert into select command.
      */
-    public void executeInsertIntoTableCommand(StmtExecutor executor) {
+    public void executeInsertIntoTableCommand(StmtExecutor executor, long jobId) {
         LOG.info("Do insert [{}] with query id: {}", labelName, DebugUtil.printId(ctx.queryId()));
         Throwable throwable = null;
 
@@ -200,11 +201,23 @@ public class Transaction {
         try {
             // the statement parsed by Nereids is saved at executor::parsedStmt.
             StatementBase statement = executor.getParsedStmt();
+            UserIdentity userIdentity;
+            //if we use job scheduler, parse statement will not set user identity,so we need to get it from context
+            if (null == statement) {
+                userIdentity = ctx.getCurrentUserIdentity();
+            } else {
+                userIdentity = statement.getUserInfo();
+            }
+            EtlJobType etlJobType = EtlJobType.INSERT;
+            if (0 != jobId) {
+                etlJobType = EtlJobType.INSERT_JOB;
+            }
+
             ctx.getEnv().getLoadManager()
                     .recordFinishedLoadJob(labelName, txnId, database.getFullName(),
                             table.getId(),
-                            EtlJobType.INSERT, createAt, throwable == null ? "" : throwable.getMessage(),
-                            coordinator.getTrackingUrl(), statement.getUserInfo());
+                            etlJobType, createAt, throwable == null ? "" : throwable.getMessage(),
+                            coordinator.getTrackingUrl(), userIdentity, jobId);
         } catch (MetaNotFoundException e) {
             LOG.warn("Record info of insert load with error {}", e.getMessage(), e);
             errMsg = "Record info of insert load with error " + e.getMessage();
diff --git a/fe/fe-core/src/main/java/org/apache/doris/persist/AlterMTMV.java b/fe/fe-core/src/main/java/org/apache/doris/persist/AlterMTMV.java
new file mode 100644
index 00000000000..d2084ff6fa3
--- /dev/null
+++ b/fe/fe-core/src/main/java/org/apache/doris/persist/AlterMTMV.java
@@ -0,0 +1,150 @@
+// 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.
+
+package org.apache.doris.persist;
+
+import org.apache.doris.common.io.Text;
+import org.apache.doris.common.io.Writable;
+import org.apache.doris.job.extensions.mtmv.MTMVTask;
+import org.apache.doris.mtmv.MTMVAlterOpType;
+import org.apache.doris.mtmv.MTMVRefreshInfo;
+import org.apache.doris.mtmv.MTMVRelation;
+import org.apache.doris.mtmv.MTMVStatus;
+import org.apache.doris.nereids.trees.plans.commands.info.TableNameInfo;
+import org.apache.doris.persist.gson.GsonUtils;
+
+import com.google.gson.annotations.SerializedName;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.util.Map;
+import java.util.Objects;
+
+public class AlterMTMV implements Writable {
+    @SerializedName("ot")
+    private MTMVAlterOpType opType;
+    @SerializedName("mn")
+    private TableNameInfo mvName;
+    @SerializedName("ri")
+    private MTMVRefreshInfo refreshInfo;
+    @SerializedName("s")
+    private MTMVStatus status;
+    @SerializedName("nrj")
+    private boolean needRebuildJob = false;
+    @SerializedName("mp")
+    private Map<String, String> mvProperties;
+    @SerializedName("t")
+    private MTMVTask task;
+    @SerializedName("r")
+    private MTMVRelation relation;
+
+    public AlterMTMV(TableNameInfo mvName, MTMVRefreshInfo refreshInfo, MTMVAlterOpType opType) {
+        this.mvName = Objects.requireNonNull(mvName, "require mvName object");
+        this.refreshInfo = Objects.requireNonNull(refreshInfo, "require refreshInfo object");
+        this.opType = Objects.requireNonNull(opType, "require opType object");
+        this.needRebuildJob = true;
+    }
+
+    public AlterMTMV(TableNameInfo mvName, MTMVAlterOpType opType) {
+        this.mvName = Objects.requireNonNull(mvName, "require mvName object");
+        this.opType = Objects.requireNonNull(opType, "require opType object");
+    }
+
+    public TableNameInfo getMvName() {
+        return mvName;
+    }
+
+    public MTMVStatus getStatus() {
+        return status;
+    }
+
+    public boolean isNeedRebuildJob() {
+        return needRebuildJob;
+    }
+
+    public MTMVRefreshInfo getRefreshInfo() {
+        return refreshInfo;
+    }
+
+    public void setMvName(TableNameInfo mvName) {
+        this.mvName = mvName;
+    }
+
+    public void setRefreshInfo(MTMVRefreshInfo refreshInfo) {
+        this.refreshInfo = refreshInfo;
+    }
+
+    public void setStatus(MTMVStatus status) {
+        this.status = status;
+    }
+
+    public void setMvProperties(Map<String, String> mvProperties) {
+        this.mvProperties = mvProperties;
+    }
+
+    public Map<String, String> getMvProperties() {
+        return mvProperties;
+    }
+
+    public void setNeedRebuildJob(boolean needRebuildJob) {
+        this.needRebuildJob = needRebuildJob;
+    }
+
+    public MTMVAlterOpType getOpType() {
+        return opType;
+    }
+
+    public MTMVTask getTask() {
+        return task;
+    }
+
+    public void setTask(MTMVTask task) {
+        this.task = task;
+    }
+
+    public MTMVRelation getRelation() {
+        return relation;
+    }
+
+    public void setRelation(MTMVRelation relation) {
+        this.relation = relation;
+    }
+
+    @Override
+    public String toString() {
+        return "AlterMTMV{"
+                + "mvName=" + mvName
+                + ", refreshInfo=" + refreshInfo
+                + ", status=" + status
+                + ", needRebuildJob=" + needRebuildJob
+                + ", mvProperties=" + mvProperties
+                + ", task=" + task
+                + ", relation=" + relation
+                + '}';
+    }
+
+    @Override
+    public void write(DataOutput out) throws IOException {
+        Text.writeString(out, GsonUtils.GSON.toJson(this));
+    }
+
+    public static AlterMTMV read(DataInput in) throws IOException {
+        return GsonUtils.GSON.fromJson(Text.readString(in), AlterMTMV.class);
+    }
+
+}
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 f34d0c2c69d..c5da3e600e5 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
@@ -1111,6 +1111,11 @@ public class EditLog {
                     env.getAnalysisManager().replayTableStatsDeletion((TableStatsDeletionLog) journal.getData());
                     break;
                 }
+                case OperationType.OP_ALTER_MTMV: {
+                    final AlterMTMV alterMtmv = (AlterMTMV) journal.getData();
+                    env.getAlterInstance().processAlterMTMV(alterMtmv, true);
+                    break;
+                }
                 default: {
                     IOException e = new IOException();
                     LOG.error("UNKNOWN Operation Type {}", opCode, e);
@@ -1936,4 +1941,8 @@ public class EditLog {
     public void logDeleteTableStats(TableStatsDeletionLog log) {
         logEdit(OperationType.OP_DELETE_TABLE_STATS, log);
     }
+
+    public void logAlterMTMV(AlterMTMV log) {
+        logEdit(OperationType.OP_ALTER_MTMV, log);
+    }
 }
diff --git a/fe/fe-core/src/main/java/org/apache/doris/persist/OperationType.java b/fe/fe-core/src/main/java/org/apache/doris/persist/OperationType.java
index 6484a9a041f..0769cba0d81 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/persist/OperationType.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/persist/OperationType.java
@@ -346,6 +346,8 @@ public class OperationType {
 
     public static final short OP_ALTER_CATALOG_COMMENT = 458;
 
+    public static final short OP_ALTER_MTMV = 459;
+
     /**
      * Get opcode name by op code.
      **/
diff --git a/fe/fe-core/src/main/java/org/apache/doris/persist/gson/GsonUtils.java b/fe/fe-core/src/main/java/org/apache/doris/persist/gson/GsonUtils.java
index f4671287801..5e4792cf4f0 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/persist/gson/GsonUtils.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/persist/gson/GsonUtils.java
@@ -76,6 +76,7 @@ import org.apache.doris.datasource.paimon.PaimonFileExternalCatalog;
 import org.apache.doris.datasource.paimon.PaimonHMSExternalCatalog;
 import org.apache.doris.job.base.AbstractJob;
 import org.apache.doris.job.extensions.insert.InsertJob;
+import org.apache.doris.job.extensions.mtmv.MTMVJob;
 import org.apache.doris.load.loadv2.LoadJob.LoadJobStateUpdateInfo;
 import org.apache.doris.load.loadv2.SparkLoadJob.SparkLoadJobStateUpdateInfo;
 import org.apache.doris.load.routineload.AbstractDataSourceProperties;
@@ -218,9 +219,9 @@ public class GsonUtils {
                             AbstractDataSourceProperties.class, "clazz")
                     .registerSubtype(KafkaDataSourceProperties.class, KafkaDataSourceProperties.class.getSimpleName());
     private static RuntimeTypeAdapterFactory<AbstractJob> jobExecutorRuntimeTypeAdapterFactory =
-            RuntimeTypeAdapterFactory.of(
-                            AbstractJob.class, "clazz")
-                    .registerSubtype(InsertJob.class, InsertJob.class.getSimpleName());
+            RuntimeTypeAdapterFactory.of(AbstractJob.class, "clazz")
+                    .registerSubtype(InsertJob.class, InsertJob.class.getSimpleName())
+                    .registerSubtype(MTMVJob.class, MTMVJob.class.getSimpleName());
 
     private static RuntimeTypeAdapterFactory<DatabaseIf> dbTypeAdapterFactory = RuntimeTypeAdapterFactory.of(
                     DatabaseIf.class, "clazz")
diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/DdlExecutor.java b/fe/fe-core/src/main/java/org/apache/doris/qe/DdlExecutor.java
index 2013216742b..5a2bae1ee05 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/DdlExecutor.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/DdlExecutor.java
@@ -122,6 +122,7 @@ import org.apache.doris.catalog.Env;
 import org.apache.doris.common.DdlException;
 import org.apache.doris.common.util.ProfileManager;
 import org.apache.doris.job.common.JobStatus;
+import org.apache.doris.job.common.JobType;
 import org.apache.doris.load.sync.SyncJobManager;
 import org.apache.doris.persist.CleanQueryStatsInfo;
 import org.apache.doris.statistics.StatisticsRepository;
@@ -184,16 +185,32 @@ public class DdlExecutor {
         } else if (ddlStmt instanceof AlterRoutineLoadStmt) {
             env.getRoutineLoadManager().alterRoutineLoadJob((AlterRoutineLoadStmt) ddlStmt);
         } else if (ddlStmt instanceof CreateJobStmt) {
-            env.getJobManager().registerJob(((CreateJobStmt) ddlStmt).getJobInstance());
+            try {
+                env.getJobManager().registerJob(((CreateJobStmt) ddlStmt).getJobInstance());
+            } catch (Exception e) {
+                throw new DdlException(e.getMessage());
+            }
         } else if (ddlStmt instanceof StopJobStmt) {
             StopJobStmt stmt = (StopJobStmt) ddlStmt;
-            env.getJobManager().unregisterJob(stmt.getDbFullName(), stmt.getName());
+            try {
+                env.getJobManager().unregisterJob(stmt.getName(), JobType.INSERT);
+            } catch (Exception e) {
+                throw new DdlException(e.getMessage());
+            }
         } else if (ddlStmt instanceof PauseJobStmt) {
             PauseJobStmt stmt = (PauseJobStmt) ddlStmt;
-            env.getJobManager().alterJobStatus(stmt.getDbFullName(), stmt.getName(), JobStatus.PAUSED);
+            try {
+                env.getJobManager().alterJobStatus(stmt.getName(), JobStatus.PAUSED, JobType.INSERT);
+            } catch (Exception e) {
+                throw new DdlException(e.getMessage());
+            }
         } else if (ddlStmt instanceof ResumeJobStmt) {
             ResumeJobStmt stmt = (ResumeJobStmt) ddlStmt;
-            env.getJobManager().alterJobStatus(stmt.getDbFullName(), stmt.getName(), JobStatus.RUNNING);
+            try {
+                env.getJobManager().alterJobStatus(stmt.getName(), JobStatus.RUNNING, JobType.INSERT);
+            } catch (Exception e) {
+                throw new DdlException(e.getMessage());
+            }
         } else if (ddlStmt instanceof CreateUserStmt) {
             CreateUserStmt stmt = (CreateUserStmt) ddlStmt;
             env.getAuth().createUser(stmt);
diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java b/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java
index 1fcaa56ddf0..3adfbc0d1a6 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java
@@ -438,6 +438,8 @@ public class SessionVariable implements Serializable, Writable {
 
     public static final String ENABLE_DECIMAL256 = "enable_decimal256";
 
+    public static final String ENABLE_EXTERNAL_MV_REWRITE = "enable_external_mv_rewrite";
+    public static final String ENABLE_MV_REWRITE = "enable_mv_rewrite";
     public static final String STATS_INSERT_MERGE_ITEM_COUNT = "stats_insert_merge_item_count";
 
     public static final String HUGE_TABLE_DEFAULT_SAMPLE_ROWS = "huge_table_default_sample_rows";
@@ -766,6 +768,11 @@ public class SessionVariable implements Serializable, Writable {
     @VariableMgr.VarAttr(name = TRIM_TAILING_SPACES_FOR_EXTERNAL_TABLE_QUERY, needForward = true)
     public boolean trimTailingSpacesForExternalTableQuery = false;
 
+    @VariableMgr.VarAttr(name = ENABLE_EXTERNAL_MV_REWRITE, needForward = true)
+    public boolean enableExternalMvRewrite = false;
+
+    @VariableMgr.VarAttr(name = ENABLE_MV_REWRITE, needForward = true)
+    public boolean enableMvRewrite = false;
 
     // the maximum size in bytes for a table that will be broadcast to all be nodes
     // when performing a join, By setting this value to -1 broadcasting can be disabled.
@@ -2421,6 +2428,22 @@ public class SessionVariable implements Serializable, Writable {
                         : maxTableCountUseCascadesJoinReorder;
     }
 
+    public boolean isEnableExternalMvRewrite() {
+        return enableExternalMvRewrite;
+    }
+
+    public void setEnableExternalMvRewrite(boolean enableExternalMvRewrite) {
+        this.enableExternalMvRewrite = enableExternalMvRewrite;
+    }
+
+    public boolean isEnableMvRewrite() {
+        return enableMvRewrite;
+    }
+
+    public void setEnableMvRewrite(boolean enableMvRewrite) {
+        this.enableMvRewrite = enableMvRewrite;
+    }
+
     public boolean isShowUserDefaultRole() {
         return showUserDefaultRole;
     }
diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/ShowExecutor.java b/fe/fe-core/src/main/java/org/apache/doris/qe/ShowExecutor.java
index 65440ac00dc..e1f79c6f6c5 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/ShowExecutor.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/ShowExecutor.java
@@ -180,6 +180,7 @@ import org.apache.doris.common.util.Util;
 import org.apache.doris.datasource.CatalogIf;
 import org.apache.doris.datasource.HMSExternalCatalog;
 import org.apache.doris.external.iceberg.IcebergTableCreationRecord;
+import org.apache.doris.job.task.AbstractTask;
 import org.apache.doris.load.DeleteHandler;
 import org.apache.doris.load.ExportJobState;
 import org.apache.doris.load.ExportMgr;
@@ -428,7 +429,7 @@ public class ShowExecutor {
         } else if (stmt instanceof ShowJobStmt) {
             handleShowJob();
         } else if (stmt instanceof ShowJobTaskStmt) {
-            //handleShowJobTask();
+            handleShowJobTask();
         } else if (stmt instanceof ShowConvertLSCStmt) {
             handleShowConvertLSC();
         } else {
@@ -1417,36 +1418,39 @@ public class ShowExecutor {
         resultSet = new ShowResultSet(showWarningsStmt.getMetaData(), rows);
     }
 
-    /*private void handleShowJobTask() {
+    private void handleShowJobTask() {
         ShowJobTaskStmt showJobTaskStmt = (ShowJobTaskStmt) stmt;
         List<List<String>> rows = Lists.newArrayList();
-        List<Job> jobs = Env.getCurrentEnv().getJobRegister()
-                .getJobs(showJobTaskStmt.getDbFullName(), showJobTaskStmt.getName(), showJobTaskStmt.getJobCategory(),
-                        null);
+        List<org.apache.doris.job.base.AbstractJob> jobs = Env.getCurrentEnv().getJobManager()
+                .queryJobs(showJobTaskStmt.getJobType(), showJobTaskStmt.getName());
         if (CollectionUtils.isEmpty(jobs)) {
             resultSet = new ShowResultSet(showJobTaskStmt.getMetaData(), rows);
             return;
         }
-        Job job = jobs.get(0);
-        long jobId = job.getJobId();
-        List<JobTask> jobTasks = Env.getCurrentEnv().getJobTaskManager().getJobTasks(jobId);
+        org.apache.doris.job.base.AbstractJob job = jobs.get(0);
+        List<AbstractTask> jobTasks = job.queryTasks();
         if (CollectionUtils.isEmpty(jobTasks)) {
-            resultSet = new ShowResultSet(showJobTaskStmt.getMetaData(), rows);
+            resultSet = new ShowResultSet(job.getTaskMetaData(), rows);
             return;
         }
-        for (JobTask jobTask : jobTasks) {
-            rows.add(jobTask.getShowInfo(job.getJobName()));
+        for (AbstractTask jobTask : jobTasks) {
+            rows.add(jobTask.getShowInfo());
         }
-        resultSet = new ShowResultSet(showJobTaskStmt.getMetaData(), rows);
-    }*/
+        resultSet = new ShowResultSet(job.getTaskMetaData(), rows);
+    }
 
     private void handleShowJob() throws AnalysisException {
         ShowJobStmt showJobStmt = (ShowJobStmt) stmt;
         List<List<String>> rows = Lists.newArrayList();
         // if job exists
         List<org.apache.doris.job.base.AbstractJob> jobList;
-        jobList = Env.getCurrentEnv().getJobManager()
-                .queryJobs(showJobStmt.getDbFullName(), showJobStmt.getName());
+        if (null == showJobStmt.getJobType()) {
+            jobList = Env.getCurrentEnv().getJobManager()
+                    .queryJobs(showJobStmt.getJobTypes());
+        } else {
+            jobList = Env.getCurrentEnv().getJobManager()
+                    .queryJobs(showJobStmt.getJobType(), showJobStmt.getName());
+        }
 
         if (jobList.isEmpty()) {
             resultSet = new ShowResultSet(showJobStmt.getMetaData(), rows);
@@ -1456,9 +1460,9 @@ public class ShowExecutor {
         // check auth
 
         for (org.apache.doris.job.base.AbstractJob job : jobList) {
-            rows.add(job.getCommonShowInfo());
+            rows.add(job.getShowInfo());
         }
-        resultSet = new ShowResultSet(showJobStmt.getMetaData(), rows);
+        resultSet = new ShowResultSet(jobList.get(0).getJobMetaData(), rows);
     }
 
     private void handleShowRoutineLoad() throws AnalysisException {
diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java b/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java
index 770c876ed2a..243cead688c 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java
@@ -2058,7 +2058,7 @@ public class StmtExecutor {
                         .recordFinishedLoadJob(label, txnId, insertStmt.getDbName(),
                                 insertStmt.getTargetTable().getId(),
                                 EtlJobType.INSERT, createTime, throwable == null ? "" : throwable.getMessage(),
-                                coord.getTrackingUrl(), insertStmt.getUserInfo());
+                                coord.getTrackingUrl(), insertStmt.getUserInfo(), 0L);
             } catch (MetaNotFoundException e) {
                 LOG.warn("Record info of insert load with error {}", e.getMessage(), e);
                 errMsg = "Record info of insert load with error " + e.getMessage();
diff --git a/fe/fe-core/src/main/java/org/apache/doris/tablefunction/MaterializedViewsTableValuedFunction.java b/fe/fe-core/src/main/java/org/apache/doris/tablefunction/MaterializedViewsTableValuedFunction.java
new file mode 100644
index 00000000000..a6384cfd683
--- /dev/null
+++ b/fe/fe-core/src/main/java/org/apache/doris/tablefunction/MaterializedViewsTableValuedFunction.java
@@ -0,0 +1,117 @@
+// 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.
+
+package org.apache.doris.tablefunction;
+
+import org.apache.doris.catalog.Column;
+import org.apache.doris.catalog.PrimitiveType;
+import org.apache.doris.catalog.ScalarType;
+import org.apache.doris.cluster.ClusterNamespace;
+import org.apache.doris.nereids.exceptions.AnalysisException;
+import org.apache.doris.system.SystemInfoService;
+import org.apache.doris.thrift.TMaterializedViewsMetadataParams;
+import org.apache.doris.thrift.TMetaScanRange;
+import org.apache.doris.thrift.TMetadataType;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Maps;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * The Implement of table valued function
+ * mtmvs("database" = "db1").
+ */
+public class MaterializedViewsTableValuedFunction extends MetadataTableValuedFunction {
+    public static final String NAME = "mtmvs";
+    private static final String DB = "database";
+
+    private static final ImmutableSet<String> PROPERTIES_SET = ImmutableSet.of(DB);
+
+    private static final ImmutableList<Column> SCHEMA = ImmutableList.of(
+            new Column("Id", ScalarType.createType(PrimitiveType.BIGINT)),
+            new Column("Name", ScalarType.createStringType()),
+            new Column("JobName", ScalarType.createStringType()),
+            new Column("State", ScalarType.createStringType()),
+            new Column("SchemaChangeDetail", ScalarType.createStringType()),
+            new Column("RefreshState", ScalarType.createStringType()),
+            new Column("RefreshInfo", ScalarType.createStringType()),
+            new Column("QuerySql", ScalarType.createStringType()),
+            new Column("EnvInfo", ScalarType.createStringType()),
+            new Column("MvProperties", ScalarType.createStringType()));
+
+    private static final ImmutableMap<String, Integer> COLUMN_TO_INDEX;
+
+    static {
+        ImmutableMap.Builder<String, Integer> builder = new ImmutableMap.Builder();
+        for (int i = 0; i < SCHEMA.size(); i++) {
+            builder.put(SCHEMA.get(i).getName().toLowerCase(), i);
+        }
+        COLUMN_TO_INDEX = builder.build();
+    }
+
+    public static Integer getColumnIndexFromColumnName(String columnName) {
+        return COLUMN_TO_INDEX.get(columnName.toLowerCase());
+    }
+
+    private final String databaseName;
+
+    public MaterializedViewsTableValuedFunction(Map<String, String> params) throws AnalysisException {
+        Map<String, String> validParams = Maps.newHashMap();
+        for (String key : params.keySet()) {
+            if (!PROPERTIES_SET.contains(key.toLowerCase())) {
+                throw new AnalysisException("'" + key + "' is invalid property");
+            }
+            // check ctl, db, tbl
+            validParams.put(key.toLowerCase(), params.get(key));
+        }
+        String dbName = validParams.get(DB);
+        if (dbName == null) {
+            throw new AnalysisException("Invalid mtmv metadata query");
+        }
+        this.databaseName = ClusterNamespace.getFullName(SystemInfoService.DEFAULT_CLUSTER, dbName);
+    }
+
+    @Override
+    public TMetadataType getMetadataType() {
+        return TMetadataType.MATERIALIZED_VIEWS;
+    }
+
+    @Override
+    public TMetaScanRange getMetaScanRange() {
+        TMetaScanRange metaScanRange = new TMetaScanRange();
+        metaScanRange.setMetadataType(TMetadataType.MATERIALIZED_VIEWS);
+        TMaterializedViewsMetadataParams mtmvParam = new TMaterializedViewsMetadataParams();
+        mtmvParam.setDatabase(databaseName);
+        metaScanRange.setMaterializedViewsParams(mtmvParam);
+        return metaScanRange;
+    }
+
+    @Override
+    public String getTableName() {
+        return "MaterializedViewsTableValuedFunction";
+    }
+
+    @Override
+    public List<Column> getTableColumns() throws AnalysisException {
+        return SCHEMA;
+    }
+}
+
diff --git a/fe/fe-core/src/main/java/org/apache/doris/tablefunction/MetadataGenerator.java b/fe/fe-core/src/main/java/org/apache/doris/tablefunction/MetadataGenerator.java
index c38744ba35e..00b5180fdd7 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/tablefunction/MetadataGenerator.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/tablefunction/MetadataGenerator.java
@@ -18,6 +18,8 @@
 package org.apache.doris.tablefunction;
 
 import org.apache.doris.catalog.Env;
+import org.apache.doris.catalog.MTMV;
+import org.apache.doris.catalog.Table;
 import org.apache.doris.common.AnalysisException;
 import org.apache.doris.common.ClientPool;
 import org.apache.doris.common.Pair;
@@ -26,6 +28,7 @@ import org.apache.doris.common.proc.FrontendsProcNode;
 import org.apache.doris.common.util.NetUtils;
 import org.apache.doris.common.util.TimeUtils;
 import org.apache.doris.datasource.CatalogIf;
+import org.apache.doris.datasource.InternalCatalog;
 import org.apache.doris.planner.external.iceberg.IcebergMetadataCache;
 import org.apache.doris.qe.ConnectContext;
 import org.apache.doris.qe.QueryDetail;
@@ -39,6 +42,7 @@ import org.apache.doris.thrift.TFetchSchemaTableDataRequest;
 import org.apache.doris.thrift.TFetchSchemaTableDataResult;
 import org.apache.doris.thrift.TIcebergMetadataParams;
 import org.apache.doris.thrift.TIcebergQueryType;
+import org.apache.doris.thrift.TMaterializedViewsMetadataParams;
 import org.apache.doris.thrift.TMetadataTableRequestParams;
 import org.apache.doris.thrift.TMetadataType;
 import org.apache.doris.thrift.TNetworkAddress;
@@ -93,6 +97,9 @@ public class MetadataGenerator {
             case CATALOGS:
                 result = catalogsMetadataResult(params);
                 break;
+            case MATERIALIZED_VIEWS:
+                result = mtmvMetadataResult(params);
+                break;
             case QUERIES:
                 result = queriesMetadataResult(params, request);
                 break;
@@ -476,5 +483,45 @@ public class MetadataGenerator {
         return (long) microsecond | (long) second << 20 | (long) minute << 26 | (long) hour << 32
                 | (long) day << 37 | (long) month << 42 | (long) year << 46;
     }
+
+    private static TFetchSchemaTableDataResult mtmvMetadataResult(TMetadataTableRequestParams params) {
+        if (!params.isSetMaterializedViewsMetadataParams()) {
+            return errorResult("MaterializedViews metadata params is not set.");
+        }
+
+        TMaterializedViewsMetadataParams mtmvMetadataParams = params.getMaterializedViewsMetadataParams();
+        String dbName = mtmvMetadataParams.getDatabase();
+        List<TRow> dataBatch = Lists.newArrayList();
+        TFetchSchemaTableDataResult result = new TFetchSchemaTableDataResult();
+        List<Table> tables;
+        try {
+            tables = Env.getCurrentEnv().getCatalogMgr()
+                    .getCatalogOrAnalysisException(InternalCatalog.INTERNAL_CATALOG_NAME)
+                    .getDbOrAnalysisException(dbName).getTables();
+        } catch (AnalysisException e) {
+            return errorResult(e.getMessage());
+        }
+
+        for (Table table : tables) {
+            if (table instanceof MTMV) {
+                MTMV mv = (MTMV) table;
+                TRow trow = new TRow();
+                trow.addToColumnValue(new TCell().setLongVal(mv.getId()));
+                trow.addToColumnValue(new TCell().setStringVal(mv.getName()));
+                trow.addToColumnValue(new TCell().setStringVal(mv.getJobInfo().getJobName()));
+                trow.addToColumnValue(new TCell().setStringVal(mv.getStatus().getState().name()));
+                trow.addToColumnValue(new TCell().setStringVal(mv.getStatus().getSchemaChangeDetail()));
+                trow.addToColumnValue(new TCell().setStringVal(mv.getStatus().getRefreshState().name()));
+                trow.addToColumnValue(new TCell().setStringVal(mv.getRefreshInfo().toString()));
+                trow.addToColumnValue(new TCell().setStringVal(mv.getQuerySql()));
+                trow.addToColumnValue(new TCell().setStringVal(mv.getEnvInfo().toString()));
+                trow.addToColumnValue(new TCell().setStringVal(mv.getMvProperties().toString()));
+                dataBatch.add(trow);
+            }
+        }
+        result.setDataBatch(dataBatch);
+        result.setStatus(new TStatus(TStatusCode.OK));
+        return result;
+    }
 }
 
diff --git a/fe/fe-core/src/main/java/org/apache/doris/tablefunction/MetadataTableValuedFunction.java b/fe/fe-core/src/main/java/org/apache/doris/tablefunction/MetadataTableValuedFunction.java
index cc84a29f5e9..1cea2ce048b 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/tablefunction/MetadataTableValuedFunction.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/tablefunction/MetadataTableValuedFunction.java
@@ -41,6 +41,8 @@ public abstract class MetadataTableValuedFunction extends TableValuedFunctionIf
                 return WorkloadGroupsTableValuedFunction.getColumnIndexFromColumnName(columnName);
             case CATALOGS:
                 return CatalogsTableValuedFunction.getColumnIndexFromColumnName(columnName);
+            case MATERIALIZED_VIEWS:
+                return MaterializedViewsTableValuedFunction.getColumnIndexFromColumnName(columnName);
             case QUERIES:
                 return QueriesTableValuedFunction.getColumnIndexFromColumnName(columnName);
             default:
diff --git a/fe/fe-core/src/main/java/org/apache/doris/tablefunction/TableValuedFunctionIf.java b/fe/fe-core/src/main/java/org/apache/doris/tablefunction/TableValuedFunctionIf.java
index 90472aa4845..012f163440f 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/tablefunction/TableValuedFunctionIf.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/tablefunction/TableValuedFunctionIf.java
@@ -66,6 +66,8 @@ public abstract class TableValuedFunctionIf {
                 return new WorkloadGroupsTableValuedFunction(params);
             case CatalogsTableValuedFunction.NAME:
                 return new CatalogsTableValuedFunction(params);
+            case MaterializedViewsTableValuedFunction.NAME:
+                return new MaterializedViewsTableValuedFunction(params);
             case GroupCommitTableValuedFunction.NAME:
                 return new GroupCommitTableValuedFunction(params);
             case QueriesTableValuedFunction.NAME:
diff --git a/gensrc/thrift/FrontendService.thrift b/gensrc/thrift/FrontendService.thrift
index 7d67bb1f908..e94526b4f19 100644
--- a/gensrc/thrift/FrontendService.thrift
+++ b/gensrc/thrift/FrontendService.thrift
@@ -891,6 +891,7 @@ struct TMetadataTableRequestParams {
   5: optional PlanNodes.TFrontendsMetadataParams frontends_metadata_params
   6: optional Types.TUserIdentity current_user_ident
   7: optional PlanNodes.TQueriesMetadataParams queries_metadata_params
+  8: optional PlanNodes.TMaterializedViewsMetadataParams materialized_views_metadata_params
 }
 
 struct TFetchSchemaTableDataRequest {
diff --git a/gensrc/thrift/PlanNodes.thrift b/gensrc/thrift/PlanNodes.thrift
index cb656d26def..b23889ab1dd 100644
--- a/gensrc/thrift/PlanNodes.thrift
+++ b/gensrc/thrift/PlanNodes.thrift
@@ -469,9 +469,14 @@ struct TFrontendsMetadataParams {
   1: optional string cluster_name
 }
 
+struct TMaterializedViewsMetadataParams {
+  1: optional string database
+}
+
 struct TQueriesMetadataParams {
   1: optional string cluster_name
   2: optional bool   relay_to_other_fe
+  3: optional TMaterializedViewsMetadataParams materialized_views_params
 }
 
 struct TMetaScanRange {
@@ -479,7 +484,8 @@ struct TMetaScanRange {
   2: optional TIcebergMetadataParams iceberg_params
   3: optional TBackendsMetadataParams backends_params
   4: optional TFrontendsMetadataParams frontends_params
-  5: optional TQueriesMetadataParams queries_params;
+  5: optional TQueriesMetadataParams queries_params
+  6: optional TMaterializedViewsMetadataParams materialized_views_params
 }
 
 // Specification of an individual data range which is held in its entirety
diff --git a/gensrc/thrift/Types.thrift b/gensrc/thrift/Types.thrift
index 69ad6009523..92cce3ae272 100644
--- a/gensrc/thrift/Types.thrift
+++ b/gensrc/thrift/Types.thrift
@@ -698,6 +698,7 @@ enum TMetadataType {
   FRONTENDS,
   CATALOGS,
   FRONTENDS_DISKS,
+  MATERIALIZED_VIEWS,
   QUERIES,
 }
 
diff --git a/regression-test/data/mtmv_p0/test_base_mtmv.out b/regression-test/data/mtmv_p0/test_base_mtmv.out
new file mode 100644
index 00000000000..306bda4dc37
--- /dev/null
+++ b/regression-test/data/mtmv_p0/test_base_mtmv.out
@@ -0,0 +1,19 @@
+-- This file is automatically generated. You should know what you did if you want to edit this
+-- !status --
+multi_mv_test_base_mtmv	INIT	INIT
+
+-- !status --
+multi_mv_test_base_mtmv	NORMAL	SUCCESS
+
+-- !status --
+multi_mv_test_base_mtmv	SCHEMA_CHANGE	SUCCESS
+
+-- !status --
+multi_mv_test_base_mtmv	NORMAL	SUCCESS
+
+-- !status --
+multi_mv_test_base_mtmv	SCHEMA_CHANGE	SUCCESS
+
+-- !status --
+multi_mv_test_base_mtmv	NORMAL	SUCCESS
+
diff --git a/regression-test/data/mtmv_p0/test_build_mtmv.out b/regression-test/data/mtmv_p0/test_build_mtmv.out
new file mode 100644
index 00000000000..bc43296bd48
--- /dev/null
+++ b/regression-test/data/mtmv_p0/test_build_mtmv.out
@@ -0,0 +1,61 @@
+-- This file is automatically generated. You should know what you did if you want to edit this
+-- !select --
+clz	200
+lisi	300
+zhangsang	200
+
+-- !select --
+clz	200
+lisi	300
+zhangsang	200
+
+-- !select --
+clz	200
+lisi	300
+zhangsang	200
+
+-- !select --
+clz	200
+lisi	300
+zhangsang	200
+
+-- !select --
+clz	200
+lisi	300
+zhangsang	200
+
+-- !select --
+clz	200
+lisi	300
+zhangsang	200
+
+-- !select --
+clz	200
+lisi	300
+zhangsang	200
+
+-- !select --
+clz	200
+lisi	300
+zhangsang	200
+
+-- !select --
+clz	200
+lisi	300
+zhangsang	200
+
+-- !select --
+clz	200
+lisi	300
+zhangsang	200
+
+-- !select --
+clz	200
+lisi	300
+zhangsang	200
+
+-- !select --
+clz	200
+lisi	300
+zhangsang	200
+
diff --git a/regression-test/data/mtmv_p0/test_create_mtmv.out b/regression-test/data/mtmv_p0/test_create_mtmv.out
new file mode 100644
index 00000000000..75d55317997
--- /dev/null
+++ b/regression-test/data/mtmv_p0/test_create_mtmv.out
@@ -0,0 +1,6 @@
+-- This file is automatically generated. You should know what you did if you want to edit this
+-- !select --
+clz	200
+lisi	300
+zhangsang	200
+
diff --git a/regression-test/framework/src/main/groovy/org/apache/doris/regression/suite/Suite.groovy b/regression-test/framework/src/main/groovy/org/apache/doris/regression/suite/Suite.groovy
index 9913a5381c8..f860f20e3a3 100644
--- a/regression-test/framework/src/main/groovy/org/apache/doris/regression/suite/Suite.groovy
+++ b/regression-test/framework/src/main/groovy/org/apache/doris/regression/suite/Suite.groovy
@@ -767,5 +767,46 @@ class Suite implements GroovyInterceptable {
     DebugPoint GetDebugPoint() {
         return debugPoint
     }
+
+    void waitingMTMVTaskFinished(String jobName) {
+        Thread.sleep(2000);
+        String showTasks = "SHOW MTMV JOB TASKS FOR ${jobName}"
+        List<List<String>> showTaskMetaResult = sql_meta(showTasks)
+        logger.info("showTaskMetaResult: " + showTaskMetaResult.toString())
+        int index = showTaskMetaResult.indexOf(['Status', 'CHAR'])
+        logger.info("index: " + index)
+        String status = "PENDING"
+        List<List<Object>> result
+        long startTime = System.currentTimeMillis()
+        long timeoutTimestamp = startTime + 5 * 60 * 1000 // 5 min
+        do {
+            result = sql(showTasks)
+            logger.info("result: " + result.toString())
+            if (!result.isEmpty()) {
+                status = result.last().get(index)
+            }
+            logger.info("The state of ${showTasks} is ${status}")
+            Thread.sleep(1000);
+        } while (timeoutTimestamp > System.currentTimeMillis() && (status == 'PENDING' || status == 'RUNNING'))
+        if (status != "SUCCESS") {
+            logger.info("status is not success")
+        }
+        Assert.assertEquals("SUCCESS", status)
+    }
+
+    String getJobName(String dbName, String mtmvName) {
+        String showMTMV = "select * from mtmvs('database'='${dbName}') where Name = '${mtmvName}'";
+	    logger.info(showMTMV)
+        List<List<String>> showTaskMetaResult = sql_meta(showMTMV)
+        logger.info("showTaskMetaResult: " + showTaskMetaResult.toString())
+        int index = showTaskMetaResult.indexOf(['JobName', 'TINYTEXT'])
+        logger.info("index: " + index)
+        List<List<Object>> result = sql(showMTMV)
+        logger.info("result: " + result.toString())
+        if (result.isEmpty()) {
+            Assert.fail();
+        }
+        return result.last().get(index);
+    }
 }
 
diff --git a/regression-test/suites/job_p0/test_base_insert_job.groovy b/regression-test/suites/job_p0/test_base_insert_job.groovy
new file mode 100644
index 00000000000..76d38460ffb
--- /dev/null
+++ b/regression-test/suites/job_p0/test_base_insert_job.groovy
@@ -0,0 +1,111 @@
+// 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 java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.time.Instant;
+import java.time.ZoneId;
+
+suite("test_base_insert_job") {
+    def tableName = "t_test_base_insert_job"
+    def jobName = "insert_recovery_test_base_insert_job"
+    sql """drop table if exists `${tableName}` force"""
+    sql """
+        STOP JOB for ${jobName}
+    """
+
+    sql """
+        CREATE TABLE IF NOT EXISTS `${tableName}`
+        (
+            `timestamp` DATE NOT NULL COMMENT "['0000-01-01', '9999-12-31']",
+            `type` TINYINT NOT NULL COMMENT "[-128, 127]",
+            `user_id` BIGINT COMMENT "[-9223372036854775808, 9223372036854775807]"
+        )
+            DUPLICATE KEY(`timestamp`, `type`)
+        DISTRIBUTED BY HASH(`type`) BUCKETS 1
+        PROPERTIES (
+            "replication_allocation" = "tag.location.default: 1"
+        );
+        """
+    sql """
+       CREATE JOB ${jobName}  ON SCHEDULER every 1 second   comment 'test' DO insert into ${tableName} (timestamp, type, user_id) values ('2023-03-18','1','12213');
+    """
+    Thread.sleep(2500)
+    def jobs = sql """select * from ${tableName}"""
+    println jobs
+    assert 3>=jobs.size() >= (2 as Boolean) //at least 2 records, some times 3 records
+    sql """
+        STOP JOB for ${jobName}
+    """
+    sql """drop table if exists `${tableName}` force """
+    sql """
+        CREATE TABLE IF NOT EXISTS `${tableName}`
+        (
+            `timestamp` DATE NOT NULL COMMENT "['0000-01-01', '9999-12-31']",
+            `type` TINYINT NOT NULL COMMENT "[-128, 127]",
+            `user_id` BIGINT COMMENT "[-9223372036854775808, 9223372036854775807]"
+        )
+            DUPLICATE KEY(`timestamp`, `type`)
+        DISTRIBUTED BY HASH(`type`) BUCKETS 1
+        PROPERTIES (
+            "replication_allocation" = "tag.location.default: 1"
+        );
+        """
+    def currentMs=System.currentTimeMillis()+1000;
+    def   dateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(currentMs), ZoneId.systemDefault());
+
+    def formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+    def startTime= dateTime.format(formatter);
+    sql """
+          CREATE JOB ${jobName}  ON SCHEDULER at '${startTime}'   comment 'test' DO insert into ${tableName} (timestamp, type, user_id) values ('2023-03-18','1','12213');
+     """
+
+    Thread.sleep(2500)
+
+    def datas = sql """select * from ${tableName}"""
+    println datas
+    //assert datas.size() == 1
+    try{
+        sql """
+            CREATE JOB ${jobName}  ON SCHEDULER at '${startTime}'   comment 'test' DO insert into ${tableName} (timestamp, type, user_id) values ('2023-03-18','1','12213');
+        """
+    } catch (Exception e) {
+        assert true
+    }
+    sql """
+        STOP JOB for test_one_time_error_starts
+    """
+    try{
+        sql """
+            CREATE JOB test_one_time_error_starts  ON SCHEDULER at '2023-11-13 14:18:07'   comment 'test' DO insert into ${tableName} (timestamp, type, user_id) values ('2023-03-18','1','12213');
+        """
+    } catch (Exception e) {
+        assert true
+    }
+    sql """
+        STOP JOB for test_error_starts
+    """
+    try{
+        sql """
+            CREATE JOB test_error_starts  ON SCHEDULER every 1 second ends '2023-11-13 14:18:07'   comment 'test' DO insert into ${tableName} (timestamp, type, user_id) values ('2023-03-18','1','12213');
+        """
+    } catch (Exception e) {
+        assert true
+    }
+
+
+}
diff --git a/regression-test/suites/mtmv_p0/test_base_mtmv.groovy b/regression-test/suites/mtmv_p0/test_base_mtmv.groovy
new file mode 100644
index 00000000000..62fd1cbbc9c
--- /dev/null
+++ b/regression-test/suites/mtmv_p0/test_base_mtmv.groovy
@@ -0,0 +1,96 @@
+// 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.
+
+suite("test_base_mtmv") {
+    def tableName = "t_test_base_mtmv_user"
+    def mvName = "multi_mv_test_base_mtmv"
+    def dbName = "regression_test_mtmv_p0"
+    sql """drop table if exists `${tableName}`"""
+
+    sql """
+        CREATE TABLE IF NOT EXISTS `${tableName}` (
+            event_day DATE,
+            id BIGINT,
+            username VARCHAR(20)
+        )
+        DISTRIBUTED BY HASH(id) BUCKETS 10 
+        PROPERTIES (
+            "replication_num" = "1"
+        );
+        """
+    sql """
+        INSERT INTO ${tableName} VALUES("2022-10-26",1,"clz"),("2022-10-28",2,"zhangsang"),("2022-10-29",3,"lisi");
+    """
+
+    sql """drop materialized view if exists ${mvName};"""
+
+    // IMMEDIATE MANUAL
+    sql """
+        CREATE MATERIALIZED VIEW ${mvName}
+        BUILD DEFERRED REFRESH COMPLETE ON MANUAL
+        DISTRIBUTED BY RANDOM BUCKETS 2
+        PROPERTIES ('replication_num' = '1') 
+        AS 
+        SELECT * FROM ${tableName};
+    """
+    def jobName = getJobName("regression_test_mtmv_p0", mvName);
+    order_qt_status "select Name,State,RefreshState  from mtmvs('database'='${dbName}') where Name='${mvName}'"
+     sql """
+        REFRESH MATERIALIZED VIEW ${mvName}
+    """
+    waitingMTMVTaskFinished(jobName)
+    order_qt_status "select Name,State,RefreshState  from mtmvs('database'='${dbName}') where Name='${mvName}'"
+
+    // alter table
+    sql """
+        alter table ${tableName} add COLUMN new_col INT AFTER username;
+    """
+    order_qt_status "select Name,State,RefreshState  from mtmvs('database'='${dbName}') where Name='${mvName}'"
+    sql """
+        alter table ${tableName} drop COLUMN new_col;
+    """
+    sql """
+        REFRESH MATERIALIZED VIEW ${mvName}
+    """
+    waitingMTMVTaskFinished(jobName)
+    order_qt_status "select Name,State,RefreshState  from mtmvs('database'='${dbName}') where Name='${mvName}'"
+
+    // drop table
+    sql """
+        drop table ${tableName}
+    """
+    order_qt_status "select Name,State,RefreshState  from mtmvs('database'='${dbName}') where Name='${mvName}'"
+    sql """
+        CREATE TABLE IF NOT EXISTS `${tableName}` (
+            event_day DATE,
+            id BIGINT,
+            username VARCHAR(20)
+        )
+        DISTRIBUTED BY HASH(id) BUCKETS 10
+        PROPERTIES (
+            "replication_num" = "1"
+        );
+    """
+    sql """
+        REFRESH MATERIALIZED VIEW ${mvName}
+    """
+    waitingMTMVTaskFinished(jobName)
+    order_qt_status "select Name,State,RefreshState  from mtmvs('database'='${dbName}') where Name='${mvName}'"
+    sql """
+        DROP MATERIALIZED VIEW ${mvName}
+    """
+}
diff --git a/regression-test/suites/mtmv_p0/test_build_mtmv.groovy b/regression-test/suites/mtmv_p0/test_build_mtmv.groovy
new file mode 100644
index 00000000000..a08c49a8b98
--- /dev/null
+++ b/regression-test/suites/mtmv_p0/test_build_mtmv.groovy
@@ -0,0 +1,279 @@
+// 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.
+
+suite("test_build_mtmv") {
+    def tableName = "t_test_create_mtmv_user"
+    def tableNamePv = "t_test_create_mtmv_user_pv"
+    def mvName = "multi_mv_test_create_mtmv"
+    def mvNameRenamed = "multi_mv_test_create_mtmv_renamed"
+
+    sql """drop table if exists `${tableName}`"""
+    sql """drop table if exists `${tableNamePv}`"""
+
+    sql """
+        CREATE TABLE IF NOT EXISTS `${tableName}` (
+            event_day DATE,
+            id BIGINT,
+            username VARCHAR(20)
+        )
+        DISTRIBUTED BY HASH(id) BUCKETS 10 
+        PROPERTIES (
+            "replication_num" = "1"
+        );
+        """
+    sql """
+        INSERT INTO ${tableName} VALUES("2022-10-26",1,"clz"),("2022-10-28",2,"zhangsang"),("2022-10-29",3,"lisi");
+    """
+    sql """
+        create table IF NOT EXISTS ${tableNamePv}(
+            event_day DATE,
+            id BIGINT,
+            pv BIGINT
+        )
+        DISTRIBUTED BY HASH(id) BUCKETS 10 
+        PROPERTIES (
+            "replication_num" = "1"
+        );
+    """
+
+    sql """
+        INSERT INTO ${tableNamePv} VALUES("2022-10-26",1,200),("2022-10-28",2,200),("2022-10-28",3,300);
+    """
+
+    sql """drop materialized view if exists ${mvName};"""
+    sql """drop materialized view if exists ${mvNameRenamed};"""
+
+    // IMMEDIATE MANUAL
+    sql """
+        CREATE MATERIALIZED VIEW ${mvName}
+        BUILD IMMEDIATE REFRESH COMPLETE ON MANUAL
+        DISTRIBUTED BY RANDOM BUCKETS 2
+        PROPERTIES ('replication_num' = '1') 
+        AS 
+        SELECT ${tableName}.username, ${tableNamePv}.pv FROM ${tableName}, ${tableNamePv} WHERE ${tableName}.id=${tableNamePv}.id;
+    """
+    def jobName = getJobName("regression_test_mtmv_p0", mvName);
+    println jobName
+    waitingMTMVTaskFinished(jobName)
+    order_qt_select "SELECT * FROM ${mvName}"
+    sql """
+        DROP MATERIALIZED VIEW ${mvName}
+    """
+
+    // IMMEDIATE schedule interval
+    sql """
+        CREATE MATERIALIZED VIEW ${mvName}
+        BUILD IMMEDIATE REFRESH COMPLETE ON SCHEDULE EVERY 10 SECOND
+        DISTRIBUTED BY RANDOM BUCKETS 2
+        PROPERTIES ('replication_num' = '1')
+        AS
+        SELECT ${tableName}.username, ${tableNamePv}.pv FROM ${tableName}, ${tableNamePv} WHERE ${tableName}.id=${tableNamePv}.id;
+    """
+    jobName = getJobName("regression_test_mtmv_p0", mvName);
+    println jobName
+    waitingMTMVTaskFinished(jobName)
+    order_qt_select "SELECT * FROM ${mvName}"
+    sql """
+        DROP MATERIALIZED VIEW ${mvName}
+    """
+
+    // IMMEDIATE schedule interval and start
+    sql """
+        CREATE MATERIALIZED VIEW ${mvName}
+        BUILD IMMEDIATE REFRESH COMPLETE ON SCHEDULE EVERY 10 SECOND STARTS "2023-12-13 21:07:09"
+        DISTRIBUTED BY RANDOM BUCKETS 2
+        PROPERTIES ('replication_num' = '1')
+        AS
+        SELECT ${tableName}.username, ${tableNamePv}.pv FROM ${tableName}, ${tableNamePv} WHERE ${tableName}.id=${tableNamePv}.id;
+    """
+    jobName = getJobName("regression_test_mtmv_p0", mvName);
+    println jobName
+    waitingMTMVTaskFinished(jobName)
+    order_qt_select "SELECT * FROM ${mvName}"
+    sql """
+        DROP MATERIALIZED VIEW ${mvName}
+    """
+
+    // DEFERRED MANUAL
+    sql """
+        CREATE MATERIALIZED VIEW ${mvName}
+        BUILD DEFERRED REFRESH COMPLETE ON MANUAL
+        DISTRIBUTED BY RANDOM BUCKETS 2
+        PROPERTIES ('replication_num' = '1')
+        AS
+        SELECT ${tableName}.username, ${tableNamePv}.pv FROM ${tableName}, ${tableNamePv} WHERE ${tableName}.id=${tableNamePv}.id;
+    """
+    sql """
+        REFRESH MATERIALIZED VIEW ${mvName}
+    """
+    jobName = getJobName("regression_test_mtmv_p0", mvName);
+    println jobName
+    waitingMTMVTaskFinished(jobName)
+    order_qt_select "SELECT * FROM ${mvName}"
+    sql """
+        DROP MATERIALIZED VIEW ${mvName}
+    """
+
+    // DEFERRED schedule interval
+    sql """
+        CREATE MATERIALIZED VIEW ${mvName}
+        BUILD IMMEDIATE REFRESH COMPLETE ON SCHEDULE EVERY 10 SECOND
+        DISTRIBUTED BY RANDOM BUCKETS 2
+        PROPERTIES ('replication_num' = '1')
+        AS
+        SELECT ${tableName}.username, ${tableNamePv}.pv FROM ${tableName}, ${tableNamePv} WHERE ${tableName}.id=${tableNamePv}.id;
+    """
+    jobName = getJobName("regression_test_mtmv_p0", mvName);
+    println jobName
+    waitingMTMVTaskFinished(jobName)
+    order_qt_select "SELECT * FROM ${mvName}"
+    sql """
+        DROP MATERIALIZED VIEW ${mvName}
+    """
+
+    // DEFERRED schedule interval and start
+    sql """
+        CREATE MATERIALIZED VIEW ${mvName}
+        BUILD IMMEDIATE REFRESH COMPLETE ON SCHEDULE EVERY 10 SECOND STARTS "2023-12-13 21:07:09"
+        DISTRIBUTED BY RANDOM BUCKETS 2
+        PROPERTIES ('replication_num' = '1')
+        AS
+        SELECT ${tableName}.username, ${tableNamePv}.pv FROM ${tableName}, ${tableNamePv} WHERE ${tableName}.id=${tableNamePv}.id;
+    """
+    jobName = getJobName("regression_test_mtmv_p0", mvName);
+    println jobName
+    waitingMTMVTaskFinished(jobName)
+    order_qt_select "SELECT * FROM ${mvName}"
+    sql """
+        DROP MATERIALIZED VIEW ${mvName}
+    """
+
+    // random
+    try {
+        sql """
+            CREATE MATERIALIZED VIEW ${mvName}
+            BUILD IMMEDIATE REFRESH COMPLETE ON SCHEDULE EVERY 10 SECOND STARTS "2023-12-13 21:07:09"
+            DISTRIBUTED BY RANDOM BUCKETS 2
+            PROPERTIES ('replication_num' = '1')
+            AS
+            SELECT random() as dd, ${tableName}.username, ${tableNamePv}.pv FROM ${tableName}, ${tableNamePv} WHERE ${tableName}.id=${tableNamePv}.id;
+        """
+        Assert.fail();
+    } catch (Exception e) {
+        log.info(e.getMessage())
+    }
+
+    // repeat cols
+    try {
+        sql """
+            CREATE MATERIALIZED VIEW ${mvName}
+            BUILD IMMEDIATE REFRESH COMPLETE ON SCHEDULE EVERY 10 SECOND STARTS "2023-12-13 21:07:09"
+            DISTRIBUTED BY RANDOM BUCKETS 2
+            PROPERTIES ('replication_num' = '1')
+            AS
+            SELECT ${tableName}.username, ${tableName}.username, ${tableNamePv}.pv FROM ${tableName}, ${tableNamePv} WHERE ${tableName}.id=${tableNamePv}.id;
+        """
+        Assert.fail();
+    } catch (Exception e) {
+        log.info(e.getMessage())
+    }
+
+    // alter
+    sql """
+        CREATE MATERIALIZED VIEW ${mvName}
+        BUILD IMMEDIATE REFRESH COMPLETE ON MANUAL
+        DISTRIBUTED BY RANDOM BUCKETS 2
+        PROPERTIES ('replication_num' = '1')
+        AS
+        SELECT ${tableName}.username, ${tableNamePv}.pv FROM ${tableName}, ${tableNamePv} WHERE ${tableName}.id=${tableNamePv}.id;
+    """
+    jobName = getJobName("regression_test_mtmv_p0", mvName);
+    waitingMTMVTaskFinished(jobName)
+    order_qt_select "SELECT * FROM ${mvName}"
+
+    // alter refreshMethod
+    sql """
+        alter MATERIALIZED VIEW ${mvName} REFRESH COMPLETE;
+    """
+    jobName = getJobName("regression_test_mtmv_p0", mvName);
+    waitingMTMVTaskFinished(jobName)
+    order_qt_select "SELECT * FROM ${mvName}"
+
+    // alter refreshTrigger
+    sql """
+        alter MATERIALIZED VIEW ${mvName} REFRESH ON MANUAL;
+    """
+    jobName = getJobName("regression_test_mtmv_p0", mvName);
+    waitingMTMVTaskFinished(jobName)
+    order_qt_select "SELECT * FROM ${mvName}"
+
+    // alter refreshMethod refreshTrigger
+    sql """
+        alter MATERIALIZED VIEW ${mvName} REFRESH COMPLETE ON MANUAL;
+    """
+    jobName = getJobName("regression_test_mtmv_p0", mvName);
+    waitingMTMVTaskFinished(jobName)
+    order_qt_select "SELECT * FROM ${mvName}"
+
+    // alter rename
+    sql """
+        alter Materialized View ${mvName} rename ${mvNameRenamed};
+    """
+    jobName = getJobName("regression_test_mtmv_p0", mvNameRenamed);
+    waitingMTMVTaskFinished(jobName)
+    order_qt_select "SELECT * FROM ${mvNameRenamed}"
+
+    sql """
+        DROP MATERIALIZED VIEW ${mvNameRenamed}
+    """
+
+    // drop
+    sql """
+        CREATE MATERIALIZED VIEW ${mvName}
+        BUILD IMMEDIATE REFRESH COMPLETE ON MANUAL
+        DISTRIBUTED BY RANDOM BUCKETS 2
+        PROPERTIES ('replication_num' = '1')
+        AS
+        SELECT ${tableName}.username, ${tableNamePv}.pv FROM ${tableName}, ${tableNamePv} WHERE ${tableName}.id=${tableNamePv}.id;
+    """
+    jobName = getJobName("regression_test_mtmv_p0", mvName);
+    waitingMTMVTaskFinished(jobName)
+    order_qt_select "SELECT * FROM ${mvName}"
+
+    // test use drop table
+    try {
+        sql """
+            drop table ${mvName};
+        """
+        Assert.fail();
+    } catch (Exception e) {
+        log.info(e.getMessage())
+    }
+
+    // test use drop mv
+
+    sql """
+        DROP MATERIALIZED VIEW ${mvName}
+    """
+    def jobs = sql """show mtmv job for ${jobName}"""
+    println jobs
+    assertEquals(jobs.size(), 0);
+    def tasks = sql """show mtmv job tasks for ${jobName}"""
+    println tasks
+    assertEquals(tasks.size(), 0);
+
+}


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