diff --git a/src/query/src/datafusion.rs b/src/query/src/datafusion.rs index 685f27c355..100216d24c 100644 --- a/src/query/src/datafusion.rs +++ b/src/query/src/datafusion.rs @@ -478,6 +478,21 @@ impl QueryEngine for DatafusionQueryEngine { fn engine_context(&self, query_ctx: QueryContextRef) -> QueryEngineContext { let mut state = self.state.session_state(); state.config_mut().set_extension(query_ctx.clone()); + // note that hints in "x-greptime-hints" is automatically parsed + // and set to query context's extension, so we can get it from query context. + if let Some(parallelism) = query_ctx.extension("query_parallelism") { + if let Ok(n) = parallelism.parse::() { + if n > 0 { + let new_cfg = state.config().clone().with_target_partitions(n as usize); + *state.config_mut() = new_cfg; + } + } else { + common_telemetry::warn!( + "Failed to parse query_parallelism: {}, using default value", + parallelism + ); + } + } QueryEngineContext::new(state, query_ctx) } diff --git a/src/session/src/hints.rs b/src/session/src/hints.rs index 4c0f359b84..e2a5b5fff8 100644 --- a/src/session/src/hints.rs +++ b/src/session/src/hints.rs @@ -14,10 +14,12 @@ // For the given format: `x-greptime-hints: auto_create_table=true, ttl=7d` pub const HINTS_KEY: &str = "x-greptime-hints"; +/// Deprecated, use `HINTS_KEY` instead. Notes if "x-greptime-hints" is set, keys with this prefix will be ignored. pub const HINTS_KEY_PREFIX: &str = "x-greptime-hint-"; pub const READ_PREFERENCE_HINT: &str = "read_preference"; +/// Deprecated, use `HINTS_KEY` instead. pub const HINT_KEYS: [&str; 7] = [ "x-greptime-hint-auto_create_table", "x-greptime-hint-ttl",