You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by "FrankChen021 (via GitHub)" <gi...@apache.org> on 2026/10/19 03:13:07 UTC
[PR] refactor(sql): reduce copies of query context in PlannerContext (druid)
FrankChen021 opened a new pull request, #20630:
URL: https://github.com/apache/druid/pull/20630
### Description
`PlannerContext` stored the query context as a mutable map, and every `queryContext()` call built a new `QueryContext` (a sorted copy) from it. `queryContext()` is called many times during planning.
This PR makes `PlannerContext` hold a single immutable `QueryContext` and return it directly:
- `queryContextMap()` now returns an immutable snapshot.
- The four places that wrote into that map during planning (INSERT/REPLACE segment granularity, catalog `rowsPerSegment`, REPLACE time chunks, export file format) now use the new `PlannerContext#setQueryContextParameter`, which replaces the context with an overridden copy.
- Added `QueryContext#override(QueryContextParameter<T>, T)`. It, and the existing `override(Map)`, now copy the context once instead of twice, and still keep keys sorted.
- Removed the unused `PlannerContext#addAllToQueryContext`.
<hr>
This PR has:
- [x] been self-reviewed.
- [x] added unit tests or modified existing tests to cover new code paths.
--
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: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org