Skip to content

Commit

Permalink
[BugFix]The OP_DROP_TABLE_V2 event is not fired when the drop materia…
Browse files Browse the repository at this point in the history
…lized view error occurs.

Signed-off-by: edwinhzhang <[email protected]>
  • Loading branch information
zhangheihei committed Dec 15, 2024
1 parent f6d536e commit df4f7c7
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 @@ -957,7 +957,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 @@ -178,7 +178,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 df4f7c7

Please sign in to comment.