Skip to content

refactor: migrate query context reference parameters - #20555

Open
FrankChen021 wants to merge 3 commits into
apache:masterfrom
FrankChen021:codex/migrate-query-context-reference
Open

FrankChen021 wants to merge 3 commits into
apache:masterfrom
FrankChen021:codex/migrate-query-context-reference

Conversation

@FrankChen021

@FrankChen021 FrankChen021 commented Oct 11, 2026 •

Copy link
Copy Markdown
Member

Description

Follow-up to #20198. Migrates the common query context parameters documented in query-context-reference.md (and scan-query.md) to typed QueryContextParameter descriptors.

  • Declares descriptors in QueryContextParameters with types, defaults, range constraints, deprecation metadata and documentation.
  • Replaces raw-string reads with descriptor-backed reads, and uses QueryContextBuilder where tests build context maps.
  • Adds QueryContextBuilder.putRaw for keys that don't have a descriptor yet.
  • Generates the corresponding rows in query-context-reference.md and scan-query.md from the descriptors.

Existing parameter names and defaults are unchanged.

Behavior changes

  • Integer and long parameters reject values that aren't exact integers, such as 1.5, and values out of range, instead of truncating or wrapping them. Integral values such as 5.0 or "5.0" are still accepted. Invalid values fail with Query context parameter [x] should be ....
  • Writing a null unsets a parameter: withOverriddenContext, withId(null) and the query builders' queryId(null) now remove the key, like the typed setters. Reads already treated an explicit null as unset, so an explicit null maxScatterGatherBytes now gets the server limit.
  • A null in the query context, or SET x = NULL, no longer clears a default configured with druid.query.default.context or the Broker dynamic configuration. The default applies, as if the key were not set. Previously the null reached readers, which used the built-in default. To override a configured default, set an explicit value.
  • maxSubqueryBytes is a typed string parameter that accepts auto, disabled or a non-negative number of bytes, as the subquery guardrail does. Invalid values such as SET maxSubqueryBytes = TRUE now fail during validation, and numbers such as 1e9 are now accepted.

Deprecations

The key constants replaced by descriptors are deprecated for removal: the migrated QueryContexts.*_KEY constants, BaseQuery.QUERY_ID and TimeseriesQuery.SKIP_EMPTY_BUCKETS. Use the corresponding QueryContextParameters descriptors instead.


This PR has:

  • been self-reviewed.
  • added documentation for new or modified features or behaviors.
  • added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.

This comment was marked as outdated.

FrankChen021

This comment was marked as outdated.

@FrankChen021 FrankChen021 added the Upgrade note Behavior change that requires an upgrade note label Oct 12, 2026

@FrankChen021 FrankChen021 left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The current head still removes the public TimeseriesQuery.SKIP_EMPTY_BUCKETS constant while retaining the same context key through QueryContextParameters.SKIP_EMPTY_BUCKETS. Downstream extensions or callers compiled against that established field will fail to compile after upgrading; retain a deprecated compatibility alias before merging.

Reviewed 131 of 131 changed files; findings in 1 file. This updated-head review began with the incremental diff from 0ebfbf6a9b250ad35aeab6408bed6eb1b74e0ca2 to the current head, then covered the full merge-base diff and surrounding code.

Validation: git diff --check passed for both the full and incremental committed diffs. No tests or builds were run per the static-review scope.

Severity Findings
P0 0
P1 0
P2 1
P3 0
Total 1

This is an automated review by Codex GPT-5.6-Luna(max)

After addressing the findings or replying to the comments, you can request another review from me to trigger a new automated review.

@FrankChen021
FrankChen021 force-pushed the codex/migrate-query-context-reference branch 2 times, most recently from 4ca0260 to d992c83 Compare October 13, 2026 06:37
@FrankChen021
FrankChen021 force-pushed the codex/migrate-query-context-reference branch from d992c83 to 474cf87 Compare October 13, 2026 06:57
- Merge the user context over default contexts with QueryContexts.withDefaults, so a null user value falls back to the configured default on both the SQL and native paths.
- Declare maxSubqueryBytes as a string parameter that accepts the forms the subquery guardrail accepts.
- Deprecate the key constants replaced by descriptors for removal, and migrate their remaining uses.
- Escape default descriptions and ignore CRLF line endings in the generated documentation check.

@FrankChen021 FrankChen021 left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The current head preserves compatibility aliases and correctly handles typed query-context defaults and null semantics. No merge-blocking correctness issues were found.

Reviewed all 165 of 165 files in the current merge-base diff, including surrounding callers, tests, configuration/default precedence, MSQ/server paths, compatibility APIs, and generated documentation. The packet’s file metadata listed 100 entries, so the prepared worktree’s complete current-head diff was used as authoritative.

Validation: git diff --check 308c949996 16d18f372debd94d84d63fec0dbfce1aeb115c13 passed. No builds or tests were run.


This is an automated review by Codex GPT-5.6-Luna(max)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area - Batch Ingestion Area - Documentation Area - MSQ For multi stage queries - https://github.com/apache/druid/issues/12262 Area - Querying Area - Segment Format and Ser/De Upgrade note Behavior change that requires an upgrade note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants