Skip to content

Commit

Permalink
[datafusion] prepend physical_optimizer_rule before other rules
Browse files Browse the repository at this point in the history
This is a bug fix that was introduced in restatedev#2004
Which change the order that optimizers are registered.
The reason for this is described as a comment few lines above.
  • Loading branch information
igalshilman committed Oct 16, 2024
1 parent 062429b commit ce3ad14
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions crates/storage-query-datafusion/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ use datafusion::error::DataFusionError;
use datafusion::execution::context::SQLOptions;
use datafusion::execution::runtime_env::{RuntimeConfig, RuntimeEnv};
use datafusion::execution::SessionStateBuilder;
use datafusion::physical_optimizer::PhysicalOptimizerRule;
use datafusion::physical_plan::SendableRecordBatchStream;
use datafusion::prelude::{SessionConfig, SessionContext};

Expand Down Expand Up @@ -159,6 +158,7 @@ impl QueryContext {
Ok(ctx)
}

#[allow(deprecated)]
fn new(
memory_limit: usize,
temp_folder: Option<String>,
Expand Down Expand Up @@ -225,12 +225,14 @@ impl QueryContext {
// A far more involved but potentially more robust solution would be wrap the SymmetricHashJoin in a ProjectionExec
// If this would become an issue for any reason, then we can explore that alternative.
//
let physical_optimizers: Vec<Arc<dyn PhysicalOptimizerRule + Send + Sync>> =
vec![Arc::new(physical_optimizer::JoinRewrite::new())];

state_builder = state_builder.with_physical_optimizer_rules(physical_optimizers);
let mut state = state_builder.build();

let state = state_builder.build();
let join_rewrite = Arc::new(physical_optimizer::JoinRewrite::new());
let mut optimizers = state.physical_optimizers().to_vec();
optimizers.insert(0, join_rewrite);

state = state.with_physical_optimizer_rules(optimizers);

let ctx = SessionContext::new_with_state(state);

Expand Down

0 comments on commit ce3ad14

Please sign in to comment.