springql_core/api/
spring_sink_row.rs1use crate::{
4 api::{
5 error::{Result, SpringError},
6 spring_source_row::SpringSourceRow,
7 },
8 stream_engine::{autonomous_executor::SchemalessRow, SpringValue, SqlValue},
9};
10
11#[derive(Debug)]
13pub struct SpringSinkRow(SchemalessRow);
14
15impl SpringSinkRow {
16 pub(crate) fn new(row: SchemalessRow) -> Self {
17 SpringSinkRow(row)
18 }
19
20 pub fn get_not_null_by_index<T>(&self, i_col: usize) -> Result<T>
29 where
30 T: SpringValue,
31 {
32 let sql_value = self.0.get_by_index(i_col)?;
33
34 match sql_value {
35 SqlValue::Null => Err(SpringError::Null { i_col }),
36 SqlValue::NotNull(nn_sql_value) => nn_sql_value.unpack(),
37 }
38 }
39}
40
41impl From<SpringSinkRow> for SpringSourceRow {
42 fn from(sink_row: SpringSinkRow) -> Self {
43 SpringSourceRow::new(sink_row.0)
44 }
45}