Skip to content

Commit

Permalink
[BugFix]The OP_DROP_TABLE_V2 event is not triggered when an error is …
Browse files Browse the repository at this point in the history
…reported for dropping a materialized view. (#53951)

Signed-off-by: edwinhzhang <[email protected]>
(cherry picked from commit eefc823)
  • Loading branch information
zhangheihei authored and mergify[bot] committed Dec 16, 2024
1 parent 4af2bb9 commit 22e7c99
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,22 @@ public void onDrop(Database db, boolean force, boolean replay) {
// 2. Remove from base tables
List<BaseTableInfo> baseTableInfos = getBaseTableInfos();
for (BaseTableInfo baseTableInfo : ListUtils.emptyIfNull(baseTableInfos)) {
Optional<Table> baseTableOpt = MvUtils.getTableWithIdentifier(baseTableInfo);
Optional<Table> baseTableOpt;
try {
baseTableOpt = MvUtils.getTableWithIdentifier(baseTableInfo);
} catch (Exception e) {
if (!(baseTableInfo.isInternalCatalog())) {
GlobalStateMgr.getCurrentState().getConnectorTblMetaInfoMgr().
removeConnectorTableInfo(baseTableInfo.getCatalogName(),
baseTableInfo.getDbName(),
baseTableInfo.getTableIdentifier(),
ConnectorTableInfo.builder().setRelatedMaterializedViews(
Sets.newHashSet(mvId)).build());
}
LOG.error("Failed to get base table: {}", baseTableInfo, e);
continue;
}

if (baseTableOpt.isPresent()) {
Table baseTable = baseTableOpt.get();
baseTable.removeRelatedMaterializedView(mvId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ public static ShowResultSet execute(StatementBase stmt, ConnectContext context)
} else if (re.getCause() instanceof IOException) {
throw (IOException) re.getCause();
} else if (re.getCause() != null) {
throw new DdlException(re.getCause().getMessage(), re);
throw new DdlException(re.getCause().getMessage() != null ?
re.getCause().getMessage() : re.getMessage(), re);
} else {
throw re;
}
Expand Down

0 comments on commit 22e7c99

Please sign in to comment.