diff --git a/src/daft-logical-plan/src/optimization/rules/reorder_joins/join_graph.rs b/src/daft-logical-plan/src/optimization/rules/reorder_joins/join_graph.rs index e7cd907657..cd2829664a 100644 --- a/src/daft-logical-plan/src/optimization/rules/reorder_joins/join_graph.rs +++ b/src/daft-logical-plan/src/optimization/rules/reorder_joins/join_graph.rs @@ -38,29 +38,11 @@ impl JoinOrderTree { } } - pub(super) fn iter(&self) -> JoinOrderTreeIterator { - JoinOrderTreeIterator { stack: vec![self] } - } -} - -pub(super) struct JoinOrderTreeIterator<'a> { - stack: Vec<&'a JoinOrderTree>, -} - -impl<'a> Iterator for JoinOrderTreeIterator<'a> { - type Item = usize; - - fn next(&mut self) -> Option { - while let Some(node) = self.stack.pop() { - match node { - JoinOrderTree::Relation(id) => return Some(*id), - JoinOrderTree::Join(left, right) => { - self.stack.push(left); - self.stack.push(right); - } - } + fn iter(&self) -> Box + '_> { + match self { + JoinOrderTree::Relation(id) => Box::new(std::iter::once(*id)), + JoinOrderTree::Join(left, right) => Box::new(left.iter().chain(right.iter())), } - None } }