Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Yulei-Yang committed Sep 19, 2024
1 parent e97affc commit 8a7f49e
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 4 deletions.
2 changes: 1 addition & 1 deletion fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public void processCreateMaterializedView(CreateMaterializedViewStmt stmt)
Database db = Env.getCurrentInternalCatalog().getDbOrDdlException(dbName);
Env.getCurrentInternalCatalog().checkAvailableCapacity(db);

OlapTable olapTable = (OlapTable) db.getTableWithTypeOrMetaException(tableName, TableType.OLAP);
OlapTable olapTable = (OlapTable) db.getNonTempTableOrMetaException(tableName, TableType.OLAP);
((MaterializedViewHandler) materializedViewHandler).processCreateMaterializedView(stmt, db, olapTable);
}

Expand Down
19 changes: 19 additions & 0 deletions fe/fe-core/src/main/java/org/apache/doris/catalog/Database.java
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,25 @@ public Table getTableNullable(String tableName) {
return table;
}

/**
* This is a thread-safe method when nameToTable is a concurrent hash map
*/
@Override
public Table getNonTempTableNullable(String tableName) {
if (Env.isStoredTableNamesLowerCase()) {
tableName = tableName.toLowerCase();
}
if (Env.isTableNamesCaseInsensitive()) {
tableName = lowerCaseToTableName.get(tableName.toLowerCase());
if (tableName == null) {
return null;
}
}

Table table = nameToTable.get(tableName);
return table;
}

/**
* This is a thread-safe method when idToTable is a concurrent hash map
*/
Expand Down
22 changes: 19 additions & 3 deletions fe/fe-core/src/main/java/org/apache/doris/catalog/DatabaseIf.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ default Set<String> getTableNamesOrEmptyWithLock() {

T getTableNullable(String tableName);

T getNonTempTableNullable(String tableName);

default T getTableNullableIfException(String tableName) {
try {
return getTableNullable(tableName);
Expand Down Expand Up @@ -139,6 +141,15 @@ default <E extends Exception> T getTableOrException(String tableName, java.util.
return table;
}

default <E extends Exception> T getNonTempTableOrException(String tableName,
java.util.function.Function<String, E> e) throws E {
T table = getNonTempTableNullable(tableName);
if (table == null) {
throw e.apply(tableName);
}
return table;
}

default <E extends Exception> T getTableOrException(long tableId, Function<Long, E> e) throws E {
T table = getTableNullable(tableId);
if (table == null) {
Expand All @@ -152,6 +163,11 @@ default T getTableOrMetaException(String tableName) throws MetaNotFoundException
ErrorCode.ERR_BAD_TABLE_ERROR));
}

default T getNonTempTableOrMetaException(String tableName) throws MetaNotFoundException {
return getNonTempTableOrException(tableName, t -> new MetaNotFoundException("table not found, tableName=" + t,
ErrorCode.ERR_BAD_TABLE_ERROR));
}

default T getTableOrMetaException(long tableId) throws MetaNotFoundException {
return getTableOrException(tableId, t -> new MetaNotFoundException("table not found, tableId=" + t,
ErrorCode.ERR_BAD_TABLE_ERROR));
Expand All @@ -167,11 +183,11 @@ default T getTableOrMetaException(String tableName, TableIf.TableType tableType)
return table;
}

default T getTableWithTypeOrMetaException(String tableName, TableIf.TableType tableType)
default T getNonTempTableOrMetaException(String tableName, TableIf.TableType tableType)
throws MetaNotFoundException {
T table = getTableOrMetaException(tableName);
T table = getNonTempTableOrMetaException(tableName);
TableType type = Objects.requireNonNull(table.getType());
if (type != tableType) {
if (type != tableType && type.getParentType() != tableType) {
throw new MetaNotFoundException(
"table type is not " + tableType + ", tableName=" + tableName + ", type=" + type);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,11 @@ public T getTableNullable(String tableName) {
}
}

@Override
public T getNonTempTableNullable(String tableName) {
throw new NotImplementedException("getNonTempTableNullable() is not implemented");
}

@Override
public T getTableNullable(long tableId) {
makeSureInitialized();
Expand Down

0 comments on commit 8a7f49e

Please sign in to comment.