Skip to content

Commit

Permalink
[datafusion] prepend physical_optimizer_rule before other rules (#2114)
Browse files Browse the repository at this point in the history
* [datafusion] prepend physical_optimizer_rule before the other rules

This is a bug fix that was introduced in #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 authored Oct 17, 2024
1 parent db5fa3a commit cb74485
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 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,7 @@ 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_optimizer::optimizer::PhysicalOptimizer;
use datafusion::physical_plan::SendableRecordBatchStream;
use datafusion::prelude::{SessionConfig, SessionContext};

Expand Down Expand Up @@ -225,13 +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())];
let join_rewrite = Arc::new(physical_optimizer::JoinRewrite::new());
let mut default_physical_optimizer_rules = PhysicalOptimizer::default().rules;
default_physical_optimizer_rules.insert(0, join_rewrite);

state_builder = state_builder.with_physical_optimizer_rules(physical_optimizers);
state_builder =
state_builder.with_physical_optimizer_rules(default_physical_optimizer_rules);

let state = state_builder.build();

let ctx = SessionContext::new_with_state(state);

let sql_options = SQLOptions::new()
Expand Down

0 comments on commit cb74485

Please sign in to comment.