Compare commits

...

3 Commits

Author SHA1 Message Date
discord9
b4b1c335ac chore: comment
Signed-off-by: discord9 <discord9@163.com>
2025-06-12 17:44:54 +08:00
discord9
41e97a0657 chore: per review
Signed-off-by: discord9 <discord9@163.com>
2025-06-12 17:44:54 +08:00
discord9
0eca6333e5 feat: parallelism hint in grpc
Signed-off-by: discord9 <discord9@163.com>
2025-06-12 17:44:54 +08:00
2 changed files with 14 additions and 0 deletions

View File

@@ -478,6 +478,19 @@ 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::<u64>() {
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)
}

View File

@@ -14,6 +14,7 @@
// 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";