Skip to content

Commit dc1edc4

Browse files
authored
Add operators_by_id to Logical Plan to get Nodes and their OpId (#382)
1 parent f2bdd18 commit dc1edc4

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

partiql-eval/src/plan.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,14 @@ impl<'c> EvaluatorPlanner<'c> {
8787

8888
#[inline]
8989
fn plan_eval(&mut self, lg: &LogicalPlan<BindingsOp>) -> EvalPlan {
90-
let ops = lg.operators();
9190
let flows = lg.flows();
9291

9392
let mut graph: StableGraph<_, _> = Default::default();
9493
let mut seen = HashMap::new();
9594

9695
for (s, d, w) in flows {
9796
let mut add_node = |op_id: &OpId| {
98-
let logical_op = &ops[op_id.index() - 1];
97+
let logical_op = lg.operator(*op_id).unwrap();
9998
*seen
10099
.entry(*op_id)
101100
.or_insert_with(|| graph.add_node(self.get_eval_node(logical_op)))

partiql-logical/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@ where
142142
&self.nodes
143143
}
144144

145+
/// Returns the operators of the plan with their `OpId`.
146+
pub fn operators_by_id(&self) -> impl Iterator<Item = (OpId, &T)> {
147+
self.nodes.iter().enumerate().map(|(i, n)| (OpId(i + 1), n))
148+
}
149+
145150
/// Returns the data flows of the plan.
146151
pub fn flows(&self) -> &Vec<(OpId, OpId, u8)> {
147152
&self.edges

0 commit comments

Comments
 (0)