feat(query): add runtime provider interface#8386
Conversation
Signed-off-by: discord9 <discord9@163.com>
Signed-off-by: discord9 <discord9@163.com>
There was a problem hiding this comment.
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.
Signed-off-by: discord9 <discord9@163.com>
Signed-off-by: discord9 <discord9@163.com>
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:
QueryRuntimeProvider,QueryRuntimeProviderRef, andQueryRuntimeContextin the query engine.DefaultQueryRuntimeProvider, which prepares the defaultRuntimeEnvBuilderand preserves the current runtime environment construction behavior.PluginsinQueryEngineState::new(), falling back to the default provider when none is registered.SessionConfigbeforeSessionStateis created.RuntimeEnvBuilderinto the provider so custom providers can preserve existing default setup and append their own runtime customizations.Compatibility:
Validation run locally:
cargo fmt -p querycargo test -p query query_runtime_cargo check -p querycargo clippy -p query --lib --tests -- -D warningsgit diff --checkPR Checklist
Please convert it to a draft if some of the following conditions are not met.