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