diff --git a/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVRewriteUtil.java b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVRewriteUtil.java index 5e17673a06883f..7b7d743a36bc8c 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVRewriteUtil.java +++ b/fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVRewriteUtil.java @@ -64,10 +64,16 @@ public static Collection getMTMVCanRewritePartitions(MTMV mtmv, Conne res.add(partition); continue; } - try { - if (refreshContext == null) { + if (refreshContext == null) { + try { refreshContext = MTMVRefreshContext.buildContext(mtmv); + } catch (AnalysisException e) { + LOG.warn("buildContext failed", e); + // After failure, one should quickly return to avoid repeated failures + return res; } + } + try { if (MTMVPartitionUtil.isMTMVPartitionSync(refreshContext, partition.getName(), mtmvRelation.getBaseTablesOneLevel(), Sets.newHashSet())) {