Skip to content
Snippets Groups Projects
Verified Commit 04f8ee50 authored by Denis Smirnov's avatar Denis Smirnov
Browse files

feat: extend DDL node API with 'take_ddl_node()' call

parent d35e3ccd
No related branches found
No related tags found
1 merge request!1414sbroad import
......@@ -81,4 +81,22 @@ impl Plan {
)),
}
}
/// Take DDL node from the plan arena and replace it with parameter node.
///
/// # Errors
/// - current node is not of DDL type
pub fn take_ddl_node(&mut self, node_id: usize) -> Result<Ddl, SbroadError> {
// Check that node is DDL type (before making any distructive operations).
let _ = self.get_ddl_node(node_id)?;
// Replace DDL with parameter node.
let node = std::mem::replace(self.get_mut_node(node_id)?, Node::Parameter);
match node {
Node::Ddl(ddl) => Ok(ddl),
_ => Err(SbroadError::Invalid(
Entity::Node,
Some(format!("node is not DDL type: {node:?}")),
)),
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment