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 dbbed113cfc [feature](mtmv)(4)MTMV extends Olap (#26645)
dbbed113cfc is described below

commit dbbed113cfc482624dbed29dd0413cf05b50388f
Author: zhangdong <493738...@qq.com>
AuthorDate: Thu Nov 23 14:10:36 2023 +0800

    [feature](mtmv)(4)MTMV extends Olap (#26645)
---
 .../org/apache/doris/analysis/ShowDataStmt.java    |  2 +-
 .../apache/doris/analysis/ShowPartitionsStmt.java  |  3 +--
 .../java/org/apache/doris/catalog/DatabaseIf.java  | 28 ++++++++++++++--------
 .../java/org/apache/doris/catalog/TableIf.java     |  9 +++++++
 4 files changed, 29 insertions(+), 13 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowDataStmt.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowDataStmt.java
index ac359d1eb79..ddaf27fa539 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowDataStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowDataStmt.java
@@ -244,7 +244,7 @@ public class ShowDataStmt extends ShowStmt {
             }
 
             OlapTable olapTable = (OlapTable) db
-                    .getTableOrMetaException(tableName.getTbl(), 
TableType.OLAP, TableType.MATERIALIZED_VIEW);
+                    .getTableOrMetaException(tableName.getTbl(), 
TableType.OLAP);
             long totalSize = 0;
             long totalReplicaCount = 0;
             long totalRemoteSize = 0;
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowPartitionsStmt.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowPartitionsStmt.java
index f6e9b06e0b1..1591e75232e 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowPartitionsStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowPartitionsStmt.java
@@ -125,8 +125,7 @@ public class ShowPartitionsStmt extends ShowStmt {
         }
 
         DatabaseIf db = catalog.getDbOrAnalysisException(dbName);
-        TableIf table = db.getTableOrMetaException(tblName, 
Table.TableType.OLAP, TableType.MATERIALIZED_VIEW,
-                    TableType.HMS_EXTERNAL_TABLE);
+        TableIf table = db.getTableOrMetaException(tblName, 
Table.TableType.OLAP, TableType.HMS_EXTERNAL_TABLE);
 
         if (table instanceof HMSExternalTable) {
             if (((HMSExternalTable) table).isView()) {
diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/DatabaseIf.java 
b/fe/fe-core/src/main/java/org/apache/doris/catalog/DatabaseIf.java
index 46ed88e72fe..985296c366f 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/DatabaseIf.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/DatabaseIf.java
@@ -17,6 +17,7 @@
 
 package org.apache.doris.catalog;
 
+import org.apache.doris.catalog.TableIf.TableType;
 import org.apache.doris.common.AnalysisException;
 import org.apache.doris.common.DdlException;
 import org.apache.doris.common.ErrorCode;
@@ -31,6 +32,7 @@ import org.apache.logging.log4j.Logger;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import java.util.Optional;
 import java.util.Set;
 import java.util.concurrent.TimeUnit;
@@ -158,9 +160,10 @@ public interface DatabaseIf<T extends TableIf> {
 
     default T getTableOrMetaException(String tableName, TableIf.TableType 
tableType) throws MetaNotFoundException {
         T table = getTableOrMetaException(tableName);
-        if (table.getType() != tableType) {
+        TableType type = Objects.requireNonNull(table.getType());
+        if (type != tableType && type.getParentType() != tableType) {
             throw new MetaNotFoundException(
-                    "table type is not " + tableType + ", tableName=" + 
tableName + ", type=" + table.getType());
+                    "table type is not " + tableType + ", tableName=" + 
tableName + ", type=" + type);
         }
         return table;
     }
@@ -168,7 +171,8 @@ public interface DatabaseIf<T extends TableIf> {
     default T getTableOrMetaException(String tableName, 
List<TableIf.TableType> tableTypes)
             throws MetaNotFoundException {
         T table = getTableOrMetaException(tableName);
-        if (!tableTypes.contains(table.getType())) {
+        TableType type = Objects.requireNonNull(table.getType());
+        if (!tableTypes.contains(type) && 
!tableTypes.contains(type.getParentType())) {
             throw new MetaNotFoundException(
                     "Type of " + tableName + " doesn't match, expected data 
tables=" + tableTypes);
         }
@@ -182,9 +186,10 @@ public interface DatabaseIf<T extends TableIf> {
 
     default T getTableOrMetaException(long tableId, TableIf.TableType 
tableType) throws MetaNotFoundException {
         T table = getTableOrMetaException(tableId);
-        if (table.getType() != tableType) {
+        TableType type = Objects.requireNonNull(table.getType());
+        if (type != tableType && type.getParentType() != tableType) {
             throw new MetaNotFoundException(
-                    "table type is not " + tableType + ", tableId=" + tableId 
+ ", type=" + table.getType());
+                    "table type is not " + tableType + ", tableId=" + tableId 
+ ", type=" + type);
         }
         return table;
     }
@@ -192,7 +197,8 @@ public interface DatabaseIf<T extends TableIf> {
     default T getTableOrMetaException(long tableId, List<TableIf.TableType> 
tableTypes)
             throws MetaNotFoundException {
         T table = getTableOrMetaException(tableId);
-        if (!tableTypes.contains(table.getType())) {
+        TableType type = Objects.requireNonNull(table.getType());
+        if (!tableTypes.contains(type) && 
!tableTypes.contains(type.getParentType())) {
             throw new MetaNotFoundException(
                     "Type of " + tableId + " doesn't match, expected data 
tables=" + tableTypes);
         }
@@ -205,9 +211,10 @@ public interface DatabaseIf<T extends TableIf> {
 
     default T getTableOrDdlException(String tableName, TableIf.TableType 
tableType) throws DdlException {
         T table = getTableOrDdlException(tableName);
-        if (table.getType() != tableType) {
+        TableType type = Objects.requireNonNull(table.getType());
+        if (type != tableType && type.getParentType() != tableType) {
             throw new DdlException(
-                    "table type is not " + tableType + ", tableName=" + 
tableName + ", type=" + table.getType());
+                    "table type is not " + tableType + ", tableName=" + 
tableName + ", type=" + type);
         }
         return table;
     }
@@ -218,9 +225,10 @@ public interface DatabaseIf<T extends TableIf> {
 
     default T getTableOrDdlException(long tableId, TableIf.TableType 
tableType) throws DdlException {
         T table = getTableOrDdlException(tableId);
-        if (table.getType() != tableType) {
+        TableType type = Objects.requireNonNull(table.getType());
+        if (type != tableType && type.getParentType() != tableType) {
             throw new DdlException(
-                    "table type is not " + tableType + ", tableId=" + tableId 
+ ", type=" + table.getType());
+                    "table type is not " + tableType + ", tableId=" + tableId 
+ ", type=" + type);
         }
         return table;
     }
diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/TableIf.java 
b/fe/fe-core/src/main/java/org/apache/doris/catalog/TableIf.java
index 3539d17e269..69275389585 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/TableIf.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/TableIf.java
@@ -198,6 +198,15 @@ public interface TableIf {
             }
         }
 
+        public TableType getParentType() {
+            switch (this) {
+                case MATERIALIZED_VIEW:
+                    return OLAP;
+                default:
+                    return this;
+            }
+        }
+
         public String toMysqlType() {
             switch (this) {
                 case OLAP:


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

Reply via email to