feat: expose BrokerResponse to subclasses via overridable onQueryCompletion hook#18247
Open
st-omarkhalid wants to merge 2 commits intoapache:masterfrom
Open
Conversation
…letion hook Add a protected `onQueryCompletion(RequestContext, BrokerResponse)` method to `BaseBrokerRequestHandler` so subclasses can intercept the fully-populated response (serverStats, partialResult, pools, rlsFiltersApplied, etc.) without changing the `BrokerQueryEventListener` SPI. Add a protected `createSingleStageBrokerRequestHandler(...)` factory method to `BaseBrokerStarter` so subclasses (e.g. StarTreePinotBrokerStarter) can supply a custom `SingleConnectionBrokerRequestHandler` subclass that overrides the hook. The default behaviour is unchanged: the existing SPI listener is still invoked. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ndler Verifies that the protected onQueryCompletion hook is invoked with a non-null BrokerResponse after every query, covering the new hook added alongside the factory method in BaseBrokerStarter. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #18248
Summary
This change makes it easier for subclasses to intercept the fully-populated
BrokerResponseafter a query executes successfully, without requiring changes to theBrokerQueryEventListenerSPI.Changes
BaseBrokerRequestHandler— adds a protectedonQueryCompletion(RequestContext, BrokerResponse)hook:this.onQueryCompletion(rc, response)instead of directly invoking_brokerQueryEventListener.onQueryCompletion(rc)BrokerResponseexists thereBaseBrokerStarter— adds a protectedcreateSingleStageBrokerRequestHandler(...)factory method:start()now calls this method instead ofnew SingleConnectionBrokerRequestHandler(...)directlySingleConnectionBrokerRequestHandler— no behaviour changeonQueryCompletionhookMotivation
The
BrokerQueryEventListenerSPI only receivesRequestContext, which is missing several fields that are only available onBrokerResponseafter execution completes:isPartialResult(),getPools(),getRLSFiltersApplied(),getTablesQueried(),isNumGroupsWarningLimitReached(), etc.This pattern (protected factory + protected hook) is already used in this codebase for
createWorkerManager(...)and follows standard Java extension patterns. It allows subclasses to capture the complete response for use cases like async query logging pipelines without modifying the SPI contract.Tests
BaseSingleStageBrokerRequestHandlerTest(13 tests) — all passLiteralOnlyBrokerRequestTest(8 tests) — all passonQueryCompletionstill calls the SPI listener🤖 Generated with Claude Code