raghavyadav01 opened a new pull request, #20280:
URL: https://github.com/apache/pinot/pull/20280
## Summary
The single-stage and multi-stage engines let a broker narrow routing and add
server query options through protected factory methods and hooks. The
time-series broker path had neither: `BaseBrokerStarter` built
`TimeSeriesRequestHandler` inline, and `TableScanVisitor` routed each leaf with
a request that carried no query options.
This adds `TimeSeriesRoutingCustomizer`. It runs once per leaf, after the
routing manager picks segments, on the planning thread and before dispatch. It
receives the leaf and a narrow `TimeSeriesRoutingContext`:
- the request's query options (read-only);
- the query's routing options (read-only);
- `putRoutingQueryOption`.
The customizer can narrow the leaf's routing table and add routing options.
Those options are sent with every leaf of the query. `BaseBrokerStarter` gains
a `createTimeSeriesRequestHandler` factory method, like its single-stage and
multi-stage siblings. The default `NO_OP` customizer leaves routing and plans
unchanged.
Use case: a table format with snapshots can pin every leaf of a query to one
snapshot and tell the servers which one. It honors a snapshot the caller pinned
in the request, as a broker can already do for single-stage SQL.
## Routing fixes the hook relies on
- **Empty leaf → no data.** A leaf with no segments on any server now
returns no data instead of failing with `No servers selected for the query`.
Its exchange expects zero servers and returns an empty block over the time
buckets. This resolves the TODO in `computeNumServersForExchangePlanNode`. A
leaf whose segments are *all unavailable* still fails, now with
`SERVER_SEGMENT_MISSING`.
- **Per-server fragments.** Each server now receives only the fragments of
the leaves it holds segments for. Before, every server ran every fragment and
sent a block for each, while an exchange waits for one block per server that
holds its leaf. So when a query's leaves routed to different servers, an
exchange could take an empty block in place of a server's real data.
- **Optional segments.** Optional segments (for example, newly pushed
segments not yet ONLINE in the external view) now reach the server under a new
metadata key (`$optionalSegmentMapEntry#`). They are queried if the server has
them, as in the single-stage engine. Before, they were dropped, and a server
holding only optional segments got an empty list that it decoded as one segment
named `""`.
- **Authorization first.** The query's tables are authorized before routing,
so a caller who may not query a table is refused before a customizer does any
work.
## Behavior changes / release notes
- A time-series query whose leaf has no segments in range now returns an
empty result instead of an error. If all of a leaf's segments are unavailable,
the query still fails, now with `SERVER_SEGMENT_MISSING`.
- **Mixed versions:** an old server ignores the new optional-segments key,
so it does not read optional segments. Its behavior is otherwise unchanged.
Roll servers before relying on optional segments.
- **Internal API changes in time-series planner classes:**
- `TimeSeriesQueryEnvironment` and `TableScanVisitor.createContext` now
take the customizer.
- `buildPhysicalPlan` now takes a table authorizer.
- Removed overloads: the old `TimeSeriesDispatchablePlan` constructor, the
no-arg `getSerializedServerFragments()`, and
`compileLeafServerQueryRequest(leaf, segments, ctx)`.
## Testing
New unit tests:
- `TableScanVisitorTest` (5)
- `TimeSeriesQueryEnvironmentTest` (7)
- `TimeSeriesExchangeReceiveOperatorTest` (4)
- `PhysicalTimeSeriesServerPlanVisitorTest` (2)
- `QueryRunnerSegmentListTest` (1)
- `TimeSeriesQueryDispatcherMetadataTest` (1)
Existing time-series tests still pass:
- `TimeSeriesRequestHandlerTest`
- `TimeSeriesPlanFragmenterTest`
- `TimeSeriesPlanSerdeTest`
- `ServerQueryRequestTest`
Local run on the touched modules: 78 tests, 0 failures, with checkstyle and
license checks enabled. `TimeSeriesIntegrationTest` and
`TimeSeriesAuthIntegrationTest` (22 + 22) passed against an earlier revision of
this commit. The later changes narrowed visibility and removed unused overloads.
Each routing fix has a unit test that fails without it:
- the empty leaf;
- per-server fragments;
- optional segments plus the `""` decode;
- authorization before the customizer.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]