Skip to main content

sea_orm/entity/
with_arrow.rs

1use crate::DbErr;
2use arrow::array::Array;
3use sea_query::{ColumnType, Value};
4
5pub use sea_orm_arrow::ArrowError;
6
7impl From<ArrowError> for DbErr {
8    fn from(e: ArrowError) -> Self {
9        DbErr::Type(e.to_string())
10    }
11}
12
13pub(crate) fn arrow_array_to_value(
14    array: &dyn Array,
15    col_type: &ColumnType,
16    row: usize,
17) -> Result<Value, DbErr> {
18    sea_orm_arrow::arrow_array_to_value(array, col_type, row).map_err(Into::into)
19}
20
21#[cfg(all(feature = "with-chrono", feature = "with-time"))]
22pub(crate) fn arrow_array_to_value_alt(
23    array: &dyn Array,
24    col_type: &ColumnType,
25    row: usize,
26) -> Result<Option<Value>, DbErr> {
27    sea_orm_arrow::arrow_array_to_value_alt(array, col_type, row).map_err(Into::into)
28}
29
30pub(crate) fn is_datetime_column(col_type: &ColumnType) -> bool {
31    sea_orm_arrow::is_datetime_column(col_type)
32}
33
34pub(crate) fn option_values_to_arrow_array(
35    values: &[Option<Value>],
36    data_type: &arrow::datatypes::DataType,
37) -> Result<std::sync::Arc<dyn Array>, DbErr> {
38    sea_orm_arrow::option_values_to_arrow_array(values, data_type).map_err(Into::into)
39}