From 9cc258bf62c0a11f83cb0a15bc63ccbbe84b6ea9 Mon Sep 17 00:00:00 2001 From: Kartik Khare Date: Thu, 2 Jul 2026 11:00:19 +0530 Subject: [PATCH] Add getUnavailableSegments broker hook for route-level unavailable filtering Introduce a protected getUnavailableSegments(serverBrokerRequest, routeInfo) hook in BaseSingleStageBrokerRequestHandler. The default returns routeInfo.getUnavailableSegments() unchanged, and both read sites (the main routing path and the materialized-view-split fallback) now route through it. This lets a subclass narrow the reported unavailable segments to those a query will actually read after routing-level pruning, with no behavior change for OSS or existing tables. --- .../BaseSingleStageBrokerRequestHandler.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/BaseSingleStageBrokerRequestHandler.java b/pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/BaseSingleStageBrokerRequestHandler.java index 8ba2f5934e8a..af4e6b8e6c90 100644 --- a/pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/BaseSingleStageBrokerRequestHandler.java +++ b/pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/BaseSingleStageBrokerRequestHandler.java @@ -732,7 +732,7 @@ protected BrokerResponse doHandleRequest(long requestId, String query, SqlNodeAn Set offlineExecutionServers = routeInfo.getOfflineExecutionServers(); Set realtimeExecutionServers = routeInfo.getRealtimeExecutionServers(); - List unavailableSegments = routeInfo.getUnavailableSegments(); + List unavailableSegments = getUnavailableSegments(serverBrokerRequest, routeInfo); int numPrunedSegmentsTotal = routeInfo.getNumPrunedSegmentsTotal(); // Rewrite the broker requests as the rest of the code expects them to be null or not based on whether the routing @@ -913,7 +913,7 @@ protected BrokerResponse doHandleRequest(long requestId, String query, SqlNodeAn /// as-is — its metric was already recorded at pre-split time. offlineExecutionServers = routeInfo.getOfflineExecutionServers(); realtimeExecutionServers = routeInfo.getRealtimeExecutionServers(); - unavailableSegments = routeInfo.getUnavailableSegments(); + unavailableSegments = getUnavailableSegments(serverBrokerRequest, routeInfo); numPrunedSegmentsTotal = routeInfo.getNumPrunedSegmentsTotal(); } @@ -2629,6 +2629,15 @@ protected abstract BrokerResponseNative processBrokerRequest(long requestId, Bro ServerStats serverStats, RequestContext requestContext) throws Exception; + /** + * Returns the segments to report as unavailable for this query. The default returns the route's unavailable + * segments unchanged. A subclass may narrow the set, e.g. to the segments the query will actually read after + * routing-level pruning, so the "segments unavailable" warning does not include segments the query never touches. + */ + protected List getUnavailableSegments(BrokerRequest serverBrokerRequest, TableRouteInfo routeInfo) { + return routeInfo.getUnavailableSegments(); + } + /// Processes an MV-split query by issuing two independent scatter-gather requests - one to the /// base table (for recent data beyond the MV boundary) and one to the materialized view table (for historical /// data up to the boundary) - then merging all returned `DataTable`s into a single