Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: put PipelineChecker at the end #5092

Merged
merged 1 commit into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/query/src/query_engine/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ use datafusion::error::Result as DfResult;
use datafusion::execution::context::{QueryPlanner, SessionConfig, SessionContext, SessionState};
use datafusion::execution::runtime_env::RuntimeEnv;
use datafusion::physical_optimizer::optimizer::PhysicalOptimizer;
use datafusion::physical_optimizer::pipeline_checker::PipelineChecker;
use datafusion::physical_optimizer::PhysicalOptimizerRule;
use datafusion::physical_plan::ExecutionPlan;
use datafusion::physical_planner::{DefaultPhysicalPlanner, ExtensionPlanner, PhysicalPlanner};
use datafusion_expr::LogicalPlan as DfLogicalPlan;
Expand Down Expand Up @@ -127,6 +129,12 @@ impl QueryEngineState {
.push(Arc::new(WindowedSortPhysicalRule));
// Add rule to remove duplicate nodes generated by other rules. Run this in the last.
physical_optimizer.rules.push(Arc::new(RemoveDuplicate));
// Place PipelineChecker at the end of the list to ensure that it runs after all other rules.
Self::remove_physical_optimizer_rule(
&mut physical_optimizer.rules,
PipelineChecker {}.name(),
);
physical_optimizer.rules.push(Arc::new(PipelineChecker {}));

let session_state = SessionState::new_with_config_rt(session_config, runtime_env)
.with_analyzer_rules(analyzer.rules)
Expand Down Expand Up @@ -159,6 +167,13 @@ impl QueryEngineState {
rules.retain(|rule| rule.name() != name);
}

fn remove_physical_optimizer_rule(
rules: &mut Vec<Arc<dyn PhysicalOptimizerRule + Send + Sync>>,
name: &str,
) {
rules.retain(|rule| rule.name() != name);
}

/// Optimize the logical plan by the extension anayzer rules.
pub fn optimize_by_extension_rules(
&self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,9 @@ TQL EXPLAIN VERBOSE (0, 10, '5s') test;
|_|_|
| physical_plan after LimitAggregation_| SAME TEXT AS ABOVE_|
| physical_plan after ProjectionPushdown_| SAME TEXT AS ABOVE_|
| physical_plan after PipelineChecker_| SAME TEXT AS ABOVE_|
| physical_plan after WindowedSortRule_| SAME TEXT AS ABOVE_|
| physical_plan after RemoveDuplicateRule_| SAME TEXT AS ABOVE_|
| physical_plan after PipelineChecker_| SAME TEXT AS ABOVE_|
| physical_plan_| PromInstantManipulateExec: range=[0..0], lookback=[300000], interval=[300000], time index=[j]_|
|_|_PromSeriesNormalizeExec: offset=[0], time index=[j], filter NaN: [false]_|
|_|_PromSeriesDivideExec: tags=["k"]_|
Expand Down
Loading