reifydb_engine/flow/compiler/operator/
extend.rs1use reifydb_core::interface::catalog::flow::FlowNodeId;
5use reifydb_rql::{expression::Expression, flow::node::FlowNodeType::Extend, nodes::ExtendNode, query::QueryPlan};
6use reifydb_transaction::transaction::admin::AdminTransaction;
7use reifydb_type::Result;
8
9use crate::flow::compiler::{CompileOperator, FlowCompiler};
10
11pub(crate) struct ExtendCompiler {
12 pub input: Option<Box<QueryPlan>>,
13 pub expressions: Vec<Expression>,
14}
15
16impl From<ExtendNode> for ExtendCompiler {
17 fn from(node: ExtendNode) -> Self {
18 Self {
19 input: node.input,
20 expressions: node.extend,
21 }
22 }
23}
24
25impl CompileOperator for ExtendCompiler {
26 fn compile(self, compiler: &mut FlowCompiler, txn: &mut AdminTransaction) -> Result<FlowNodeId> {
27 let input_node = if let Some(input) = self.input {
28 Some(compiler.compile_plan(txn, *input)?)
29 } else {
30 None
31 };
32
33 let node_id = compiler.add_node(
34 txn,
35 Extend {
36 expressions: self.expressions,
37 },
38 )?;
39
40 if let Some(input) = input_node {
41 compiler.add_edge(txn, &input, &node_id)?;
42 }
43
44 Ok(node_id)
45 }
46}