Skip to content

feat(query): add runtime provider interface#8386

Open
discord9 wants to merge 4 commits into
GreptimeTeam:mainfrom
discord9:exp/query-runtime-interface
Open

feat(query): add runtime provider interface#8386
discord9 wants to merge 4 commits into
GreptimeTeam:mainfrom
discord9:exp/query-runtime-interface

Conversation

@discord9

@discord9 discord9 commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

I hereby agree to the terms of the GreptimeDB CLA.

Refer to a related PR or issue link (optional)

What's changed and what's your intention?

This PR adds a neutral query runtime provider interface for DataFusion session and runtime setup.

Changes included:

  • Add QueryRuntimeProvider, QueryRuntimeProviderRef, and QueryRuntimeContext in the query engine.
  • Add DefaultQueryRuntimeProvider, which prepares the default RuntimeEnvBuilder and preserves the current runtime environment construction behavior.
  • Resolve a provider from Plugins in QueryEngineState::new(), falling back to the default provider when none is registered.
  • Allow the provider to configure SessionConfig before SessionState is created.
  • Pass the default RuntimeEnvBuilder into the provider so custom providers can preserve existing default setup and append their own runtime customizations.
  • Add focused unit tests for default behavior and plugin-provided provider behavior.

Compatibility:

  • No user-facing configuration changes.
  • No example config, generated config docs, or product docs changes.
  • Default behavior remains unchanged when no provider is registered.
  • No persisted format, schema, or wire format changes are introduced.

Validation run locally:

  • cargo fmt -p query
  • cargo test -p query query_runtime_
  • cargo check -p query
  • cargo clippy -p query --lib --tests -- -D warnings
  • git diff --check

PR Checklist

Please convert it to a draft if some of the following conditions are not met.

  • I have written the necessary rustdoc comments.
  • I have added the necessary unit tests and integration tests.
  • This PR requires documentation updates.
  • API changes are backward compatible.
  • Schema or data changes are backward compatible.

discord9 added 2 commits June 30, 2026 21:39
Signed-off-by: discord9 <discord9@163.com>
Signed-off-by: discord9 <discord9@163.com>
@github-actions github-actions Bot added size/S docs-not-required This change does not impact docs. labels Jun 30, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new QueryRuntimeProvider trait and its default implementation DefaultQueryRuntimeProvider to decouple and customize the DataFusion session configuration and runtime environment setup in the query engine. It integrates this provider into QueryEngineState by fetching it from plugins, and adds comprehensive unit tests. The review feedback focuses on improving error handling and code ergonomics by: 1) deriving Clone and Copy for QueryRuntimeContext to allow easy reuse, 2) changing the build_runtime_env method in the QueryRuntimeProvider trait to return a Result instead of panicking, and propagating errors using the ? operator across the default provider, state initialization, and test implementations, and 3) reusing a single QueryRuntimeContext instance in QueryEngineState instead of reconstructing it.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/query/src/query_engine/runtime.rs
Comment thread src/query/src/query_engine/runtime.rs Outdated
Comment thread src/query/src/query_engine/runtime.rs Outdated
Comment thread src/query/src/query_engine/state.rs Outdated
Comment thread src/query/src/query_engine/state.rs Outdated
Signed-off-by: discord9 <discord9@163.com>
@discord9 discord9 marked this pull request as ready for review July 1, 2026 08:47
@discord9 discord9 requested review from evenyag and waynexia as code owners July 1, 2026 08:47
Signed-off-by: discord9 <discord9@163.com>
@github-actions github-actions Bot added size/M and removed size/S labels Jul 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs-not-required This change does not impact docs. size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant