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