Skip to content

Commit

Permalink
apply rule works for expr instead of group (#44)
Browse files Browse the repository at this point in the history
Signed-off-by: AveryQi115 <averyqi115@gmail.com>
  • Loading branch information
AveryQi115 authored Jan 31, 2024
1 parent 90d254b commit 5e067be
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion optd-core/src/cascades/tasks/apply_rule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,15 @@ fn match_node<T: RelNodeTyp>(
picks
}

fn match_and_pick_expr<T: RelNodeTyp>(
matcher: &RuleMatcher<T>,
expr_id: ExprId,
optimizer: &CascadesOptimizer<T>,
) -> Vec<HashMap<usize, RelNode<T>>> {
let node = optimizer.get_expr_memoed(expr_id);
match_and_pick(matcher, node, optimizer)
}

fn match_and_pick_group<T: RelNodeTyp>(
matcher: &RuleMatcher<T>,
group_id: GroupId,
Expand Down Expand Up @@ -183,7 +192,7 @@ impl<T: RelNodeTyp> Task<T> for ApplyRuleTask {
trace!(event = "task_begin", task = "apply_rule", expr_id = %self.expr_id, rule_id = %self.rule_id, rule = %rule.name());
let group_id = optimizer.get_group_id(self.expr_id);
let mut tasks = vec![];
let binding_exprs = match_and_pick_group(rule.matcher(), group_id, optimizer);
let binding_exprs = match_and_pick_expr(rule.matcher(), self.expr_id, optimizer);
for expr in binding_exprs {
let applied = rule.apply(optimizer, expr);
for expr in applied {
Expand Down

0 comments on commit 5e067be

Please sign in to comment.