reifydb_engine/flow/compiler/operator/
append.rs1use reifydb_core::{interface::catalog::flow::FlowNodeId, row::Ttl};
5use reifydb_rql::{flow::node::FlowNodeType, nodes::AppendQueryNode, query::QueryPlan};
6use reifydb_transaction::transaction::Transaction;
7use reifydb_value::Result;
8
9use crate::flow::compiler::{CompileOperator, FlowCompiler};
10
11pub(crate) struct AppendCompiler {
12 pub left: Box<QueryPlan>,
13 pub right: Box<QueryPlan>,
14 pub ttl: Option<Ttl>,
15}
16
17impl From<AppendQueryNode> for AppendCompiler {
18 fn from(node: AppendQueryNode) -> Self {
19 Self {
20 left: node.left,
21 right: node.right,
22 ttl: node.ttl,
23 }
24 }
25}
26
27impl CompileOperator for AppendCompiler {
28 fn compile(self, compiler: &mut FlowCompiler, txn: &mut Transaction<'_>) -> Result<FlowNodeId> {
29 let left_node = compiler.compile_plan(txn, *self.left)?;
30 let right_node = compiler.compile_plan(txn, *self.right)?;
31
32 let node_id = compiler.add_node(txn, FlowNodeType::Append {})?;
33
34 compiler.write_operator_settings(txn, node_id, self.ttl)?;
35
36 compiler.add_edge(txn, &left_node, &node_id)?;
37 compiler.add_edge(txn, &right_node, &node_id)?;
38
39 Ok(node_id)
40 }
41}