diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/TopnFilterPushDownVisitor.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/TopnFilterPushDownVisitor.java index 95cdbd9cc96af0..a6c97cf4267741 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/TopnFilterPushDownVisitor.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/TopnFilterPushDownVisitor.java @@ -218,7 +218,9 @@ public Boolean visitPhysicalNestedLoopJoin(PhysicalNestedLoopJoin ctx.topn.getLimit() + ctx.topn.getOffset()) { + // in ut, relation.getStats() may return null + if (relation.getStats() == null + || relation.getStats().getRowCount() > ctx.topn.getLimit() + ctx.topn.getOffset()) { topnFilterContext.addTopnFilter(ctx.topn, relation, ctx.probeExpr); return true; } @@ -226,6 +228,7 @@ public Boolean visitPhysicalRelation(PhysicalRelation relation, PushDownContext return false; } + private boolean supportPhysicalRelations(PhysicalRelation relation) { return relation instanceof PhysicalOlapScan || relation instanceof PhysicalOdbcScan