Skip to content

Commit d8b8eab

Browse files
committed
chore(cubestore): Upgrade DF: Factor out QueryPlannerImpl::make_execution_context
1 parent 148da91 commit d8b8eab

File tree

1 file changed

+11
-4
lines changed
  • rust/cubestore/cubestore/src/queryplanner

1 file changed

+11
-4
lines changed

rust/cubestore/cubestore/src/queryplanner/mod.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,9 @@ impl QueryPlannerImpl {
243243
}
244244

245245
impl QueryPlannerImpl {
246-
async fn execution_context(&self) -> Result<Arc<SessionContext>, CubeError> {
246+
pub fn make_execution_context() -> SessionContext {
247247
let context = SessionContext::new();
248-
// TODO upgrade DF: build SessionContexts consistently
248+
// TODO upgrade DF: build SessionContexts consistently -- that now means check all appropriate SessionContext constructors use this make_execution_context or execution_context function.
249249
for udaf in registerable_aggregate_udfs() {
250250
context.register_udaf(udaf);
251251
}
@@ -260,7 +260,11 @@ impl QueryPlannerImpl {
260260
// TODO upgrade DF
261261
// context
262262
// .add_optimizer_rule(Arc::new(ProjectionAboveLimit {})),
263-
Ok(Arc::new(context))
263+
context
264+
}
265+
266+
async fn execution_context(&self) -> Result<Arc<SessionContext>, CubeError> {
267+
Ok(Arc::new(Self::make_execution_context()))
264268
}
265269
}
266270

@@ -504,10 +508,11 @@ impl ContextProvider for MetaStoreSchemaProvider {
504508
}
505509

506510
fn get_window_meta(&self, name: &str) -> Option<Arc<WindowUDF>> {
511+
// TODO upgrade DF: Should this also use .to_ascii_lowercase?
507512
self.session_state.window_functions().get(name).cloned()
508513
}
509514

510-
fn get_variable_type(&self, variable_names: &[String]) -> Option<DataType> {
515+
fn get_variable_type(&self, _variable_names: &[String]) -> Option<DataType> {
511516
None
512517
}
513518

@@ -516,6 +521,7 @@ impl ContextProvider for MetaStoreSchemaProvider {
516521
}
517522

518523
fn udf_names(&self) -> Vec<String> {
524+
// TODO upgrade DF: Because we register the scalar functions (see get_function_meta) we shouldn't need to prepend the list here.
519525
let mut res = vec![
520526
"date_add".to_string(),
521527
"date_sub".to_string(),
@@ -526,6 +532,7 @@ impl ContextProvider for MetaStoreSchemaProvider {
526532
}
527533

528534
fn udaf_names(&self) -> Vec<String> {
535+
// TODO upgrade DF: We shouldn't need "merge" here because we registered it (see get_aggregate_meta).
529536
let mut res = vec!["merge".to_string()];
530537
res.extend(self.session_state.aggregate_functions().keys().cloned());
531538
res

0 commit comments

Comments
 (0)