risingwave_connector/parser/unified/
util.rs1use super::{AccessResult, ChangeEvent};
16use crate::parser::SourceStreamChunkRowWriter;
17use crate::parser::unified::ChangeEventOperation;
18use crate::source::SourceColumnDesc;
19
20pub fn apply_row_operation_on_stream_chunk_writer_with_op(
21 row_op: impl ChangeEvent,
22 writer: &mut SourceStreamChunkRowWriter<'_>,
23 op: ChangeEventOperation,
24) -> AccessResult<()> {
25 let f = |column: &SourceColumnDesc| row_op.access_field(column);
26 match op {
27 ChangeEventOperation::Upsert => writer.do_insert(f),
28 ChangeEventOperation::Delete => writer.do_delete(f),
29 }
30}
31
32pub fn apply_row_operation_on_stream_chunk_writer(
33 row_op: impl ChangeEvent,
34 writer: &mut SourceStreamChunkRowWriter<'_>,
35) -> AccessResult<()> {
36 let op = row_op.op()?;
37 apply_row_operation_on_stream_chunk_writer_with_op(row_op, writer, op)
38}