You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Run selected DataFusion optimizer rules in SQL lowering; a rule-list API for ASAPPlanner rewrites #670
DataFusion lets a caller run an optimizer with an explicit list of rules:
let plan = datafusion::optimizer::Optimizer::with_rules(vec![Arc::new(
datafusion::optimizer::simplify_expressions::SimplifyExpressions::new(),)]).optimize(plan,&ctx.state(), |_, _| {})?;
Two uses:
In the SQL frontend: run a chosen set of DataFusion optimizer rules once during lowering, before the plan is converted to the unified IR.
In ASAPPlanner: expose a similar API for our own rewrite rules, i.e. register rules by name and run a pipeline built from them. Canonicalization and the Stage 1 rewrite rules would be the first candidates.
It deliberately avoids Analyzer::execute_and_check, because that runs an unconditional check_plan. No DataFusion optimizer rules run; we lower the unoptimized plan.
Questions to settle
Which rules are safe. A rule must keep the semantics the unified IR can express, and must not produce constructs that lowering rejects. Some rules need a closer look before adopting:
subquery decorrelation, which turns subqueries into joins;
CommonSubexprEliminate, which may conflict with our own sub-DAG sharing (Pass 2);
Order versus our canonicalization. Which of our canonicalization steps become unnecessary after the DataFusion rules, and which must stay because PromQL and MetricsQL don't go through DataFusion.
Our rule API. What the ASAPPlanner equivalent looks like, e.g. Rewriter::with_rules(vec![...]).rewrite(dag). Keep it minimal: a rule is a function from DAG to DAG plus a name. No new framework.
Activity