[feature](mtmv)(4)MTMV extends Olap (#26645)

This commit is contained in:
zhangdong
2023-11-23 14:10:36 +08:00
committed by GitHub
parent 4fc638c98c
commit dbbed113cf
4 changed files with 29 additions and 13 deletions

View File

@ -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;

View File

@ -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()) {

View File

@ -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;
}

View File

@ -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: