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

eldenmoon 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 a027db19705 [fix](mtmv)Mtmv support row column (#35860)
a027db19705 is described below

commit a027db1970568ca8e19f0b97d9a94ba15e35e591
Author: zhangdong <[email protected]>
AuthorDate: Wed Jun 5 10:57:53 2024 +0800

    [fix](mtmv)Mtmv support row column (#35860)
    
    when create mtmv with property `'store_row_column' = 'true'`,and `select
    * from mtmv order by xxx limit xxx`
    be will core,before MTMV not have hidden column
    `__DORIS_ROW_STORE_COL__`
---
 .../trees/plans/commands/info/CreateMTMVInfo.java  | 13 ++++
 .../data/mtmv_p0/test_row_column_mtmv.out          | 13 ++++
 .../suites/mtmv_p0/test_row_column_mtmv.groovy     | 72 ++++++++++++++++++++++
 3 files changed, 98 insertions(+)

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 0add620d035..aeb109726e0 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
@@ -34,6 +34,7 @@ import org.apache.doris.catalog.View;
 import org.apache.doris.common.ErrorCode;
 import org.apache.doris.common.FeNameFormat;
 import org.apache.doris.common.util.DynamicPartitionUtil;
+import org.apache.doris.common.util.PropertyAnalyzer;
 import org.apache.doris.mtmv.EnvInfo;
 import org.apache.doris.mtmv.MTMVPartitionInfo;
 import org.apache.doris.mtmv.MTMVPartitionInfo.MTMVPartitionType;
@@ -335,6 +336,18 @@ public class CreateMTMVInfo {
                     CollectionUtils.isEmpty(simpleColumnDefinitions) ? null
                             : simpleColumnDefinitions.get(i).getComment()));
         }
+        // add a hidden column as row store
+        if (properties != null) {
+            try {
+                boolean storeRowColumn =
+                        
PropertyAnalyzer.analyzeStoreRowColumn(Maps.newHashMap(properties));
+                if (storeRowColumn) {
+                    
columns.add(ColumnDefinition.newRowStoreColumnDefinition(null));
+                }
+            } catch (Exception e) {
+                throw new AnalysisException(e.getMessage(), e.getCause());
+            }
+        }
     }
 
     /**
diff --git a/regression-test/data/mtmv_p0/test_row_column_mtmv.out 
b/regression-test/data/mtmv_p0/test_row_column_mtmv.out
new file mode 100644
index 00000000000..8f9122aa757
--- /dev/null
+++ b/regression-test/data/mtmv_p0/test_row_column_mtmv.out
@@ -0,0 +1,13 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !k1 --
+1      1
+
+-- !k2 --
+3      3
+
+-- !k1_k2 --
+1      1
+
+-- !k2_k1 --
+1      1
+
diff --git a/regression-test/suites/mtmv_p0/test_row_column_mtmv.groovy 
b/regression-test/suites/mtmv_p0/test_row_column_mtmv.groovy
new file mode 100644
index 00000000000..646fdcde074
--- /dev/null
+++ b/regression-test/suites/mtmv_p0/test_row_column_mtmv.groovy
@@ -0,0 +1,72 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+import org.junit.Assert;
+
+suite("test_row_column_mtmv","mtmv") {
+    String suiteName = "test_row_column_mtmv"
+    String tableName = "${suiteName}_table"
+    String mvName = "${suiteName}_mv"
+    sql """drop table if exists `${tableName}`"""
+    sql """drop materialized view if exists ${mvName};"""
+
+    sql """
+        CREATE TABLE ${tableName}
+        (
+            k1 TINYINT,
+            k2 INT not null
+        )
+        COMMENT "my first table"
+        DISTRIBUTED BY HASH(k2) BUCKETS 2
+        PROPERTIES (
+            "replication_num" = "1"
+        );
+        """
+     sql """
+        insert into ${tableName} values(1,1),(2,2),(3,3);
+        """
+    sql """
+        CREATE MATERIALIZED VIEW ${mvName}
+        BUILD DEFERRED REFRESH AUTO ON MANUAL
+        DISTRIBUTED BY RANDOM BUCKETS 2
+        PROPERTIES (
+        'replication_num' = '1',
+        'store_row_column' = 'true'
+        )
+        AS
+        SELECT * from ${tableName};
+        """
+
+     sql """
+        REFRESH MATERIALIZED VIEW ${mvName} AUTO
+        """
+    waitingMTMVTaskFinishedByMvName(mvName)
+
+    order_qt_k1 "SELECT * FROM ${mvName} order by k1 limit 1"
+    order_qt_k2 "SELECT * FROM ${mvName} order by k2 desc limit 1"
+    order_qt_k1_k2 "SELECT * FROM ${mvName} order by k1,k2 limit 1"
+    order_qt_k2_k1 "SELECT * FROM ${mvName} order by k2,k1 limit 1"
+
+    sql """SET show_hidden_columns=true;"""
+    def colRes = sql """desc ${mvName};"""
+    logger.info("colRes: " + colRes.toString())
+    assertTrue(colRes.toString().contains("__DORIS_ROW_STORE_COL__"))
+
+    sql """SET show_hidden_columns=false;"""
+    sql """drop table if exists `${tableName}`"""
+    sql """drop materialized view if exists ${mvName};"""
+}


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

Reply via email to