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

morrysnow 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 cc4f44677a4 [enhance](mtmv)support create mtmv with other mtmv (#32984)
cc4f44677a4 is described below

commit cc4f44677a4d45b296694d4a03982155d9883f80
Author: zhangdong <[email protected]>
AuthorDate: Wed Apr 3 11:49:24 2024 +0800

    [enhance](mtmv)support create mtmv with other mtmv (#32984)
---
 .../trees/plans/commands/info/CreateMTMVInfo.java  | 11 ---
 .../data/mtmv_p0/test_multi_level_mtmv.out         | 13 ++++
 .../suites/mtmv_p0/test_build_mtmv.groovy          | 15 ----
 .../suites/mtmv_p0/test_multi_level_mtmv.groovy    | 81 ++++++++++++++++++++++
 4 files changed, 94 insertions(+), 26 deletions(-)

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 7e7f58db44d..3846cd99ff1 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
@@ -29,7 +29,6 @@ import org.apache.doris.catalog.Env;
 import org.apache.doris.catalog.KeysType;
 import org.apache.doris.catalog.PartitionType;
 import org.apache.doris.catalog.TableIf;
-import org.apache.doris.catalog.TableIf.TableType;
 import org.apache.doris.catalog.View;
 import org.apache.doris.common.DdlException;
 import org.apache.doris.common.ErrorCode;
@@ -64,8 +63,6 @@ import 
org.apache.doris.nereids.trees.plans.logical.LogicalPlan;
 import org.apache.doris.nereids.trees.plans.logical.LogicalSink;
 import org.apache.doris.nereids.trees.plans.logical.LogicalSubQueryAlias;
 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 org.apache.doris.qe.SessionVariable;
@@ -319,14 +316,6 @@ public class CreateMTMVInfo {
     }
 
     private void analyzeBaseTables(Plan plan) {
-        TableCollectorContext collectorContext =
-                new 
TableCollector.TableCollectorContext(Sets.newHashSet(TableType.MATERIALIZED_VIEW),
 true);
-        plan.accept(TableCollector.INSTANCE, collectorContext);
-        Set<TableIf> collectedTables = collectorContext.getCollectedTables();
-        if (!CollectionUtils.isEmpty(collectedTables)) {
-            throw new AnalysisException("can not contain MATERIALIZED_VIEW");
-        }
-
         List<Object> subQuerys = plan.collectToList(node -> node instanceof 
LogicalSubQueryAlias);
         for (Object subquery : subQuerys) {
             List<String> qualifier = ((LogicalSubQueryAlias) 
subquery).getQualifier();
diff --git a/regression-test/data/mtmv_p0/test_multi_level_mtmv.out 
b/regression-test/data/mtmv_p0/test_multi_level_mtmv.out
new file mode 100644
index 00000000000..3d8a1e1b43f
--- /dev/null
+++ b/regression-test/data/mtmv_p0/test_multi_level_mtmv.out
@@ -0,0 +1,13 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !mv1 --
+1      1
+
+-- !mv2 --
+1      1
+
+-- !status1 --
+multi_level_mtmv1      SCHEMA_CHANGE   SUCCESS
+
+-- !status2 --
+multi_level_mtmv2      SCHEMA_CHANGE   SUCCESS
+
diff --git a/regression-test/suites/mtmv_p0/test_build_mtmv.groovy 
b/regression-test/suites/mtmv_p0/test_build_mtmv.groovy
index d0bfc756695..f0bf2c4e700 100644
--- a/regression-test/suites/mtmv_p0/test_build_mtmv.groovy
+++ b/regression-test/suites/mtmv_p0/test_build_mtmv.groovy
@@ -122,21 +122,6 @@ suite("test_build_mtmv") {
         log.info(e.getMessage())
     }
 
-    // not allow create mv use other mv
-    try {
-        sql """
-            CREATE MATERIALIZED VIEW ${mvNameRenamed}
-            BUILD DEFERRED REFRESH COMPLETE ON MANUAL
-            DISTRIBUTED BY RANDOM BUCKETS 2
-            PROPERTIES ('replication_num' = '1')
-            AS
-            SELECT * from ${mvName};
-        """
-        Assert.fail();
-    } catch (Exception e) {
-        log.info(e.getMessage())
-    }
-
     // not allow create mv use view
     try {
         sql """
diff --git a/regression-test/suites/mtmv_p0/test_multi_level_mtmv.groovy 
b/regression-test/suites/mtmv_p0/test_multi_level_mtmv.groovy
new file mode 100644
index 00000000000..81d4b78a3d7
--- /dev/null
+++ b/regression-test/suites/mtmv_p0/test_multi_level_mtmv.groovy
@@ -0,0 +1,81 @@
+// 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_multi_level_mtmv") {
+    def tableName = "t_test_multi_level_user"
+    def mv1 = "multi_level_mtmv1"
+    def mv2 = "multi_level_mtmv2"
+    def dbName = "regression_test_mtmv_p0"
+    sql """drop table if exists `${tableName}`"""
+    sql """drop materialized view if exists ${mv1};"""
+    sql """drop materialized view if exists ${mv2};"""
+
+    sql """
+        CREATE TABLE IF NOT EXISTS `${tableName}` (
+            k1 int,
+            k2 int
+        )
+        DISTRIBUTED BY HASH(k1) BUCKETS 10
+        PROPERTIES (
+            "replication_num" = "1"
+        );
+        """
+    sql """
+        INSERT INTO ${tableName} VALUES(1,1);
+    """
+
+    sql """
+        CREATE MATERIALIZED VIEW ${mv1}
+        BUILD DEFERRED REFRESH COMPLETE ON MANUAL
+        DISTRIBUTED BY RANDOM BUCKETS 2
+        PROPERTIES ('replication_num' = '1') 
+        AS 
+        SELECT * FROM ${tableName};
+    """
+    def jobName1 = getJobName("regression_test_mtmv_p0", mv1);
+     sql """
+        REFRESH MATERIALIZED VIEW ${mv1} AUTO
+    """
+    waitingMTMVTaskFinished(jobName1)
+    order_qt_mv1 "select * from ${mv1}"
+
+    sql """
+        CREATE MATERIALIZED VIEW ${mv2}
+        BUILD DEFERRED REFRESH COMPLETE ON MANUAL
+        DISTRIBUTED BY RANDOM BUCKETS 2
+        PROPERTIES ('replication_num' = '1')
+        AS
+        SELECT * FROM ${mv1};
+    """
+    def jobName2 = getJobName("regression_test_mtmv_p0", mv2);
+     sql """
+        REFRESH MATERIALIZED VIEW ${mv2} AUTO
+    """
+    waitingMTMVTaskFinished(jobName2)
+    order_qt_mv2 "select * from ${mv2}"
+
+    // drop table
+    sql """
+        drop table ${tableName}
+    """
+    order_qt_status1 "select Name,State,RefreshState  from 
mv_infos('database'='${dbName}') where Name='${mv1}'"
+    order_qt_status2 "select Name,State,RefreshState  from 
mv_infos('database'='${dbName}') where Name='${mv2}'"
+
+    sql """drop table if exists `${tableName}`"""
+    sql """drop materialized view if exists ${mv1};"""
+    sql """drop materialized view if exists ${mv2};"""
+}


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

Reply via email to