Skip to content

Commit c650614

Browse files
committed
Do not depends on arrow directly
1 parent 23fe04d commit c650614

8 files changed

Lines changed: 21 additions & 19 deletions

File tree

sea-orm-sync/src/entity/active_model.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ pub trait ActiveModelTrait: Clone + Debug {
535535
/// are attempted first. If the model uses time-crate types, the conversion
536536
/// automatically falls back to the time-crate representation.
537537
#[cfg(feature = "with-arrow")]
538-
fn from_arrow(batch: &arrow::array::RecordBatch) -> Result<Vec<Self>, DbErr> {
538+
fn from_arrow(batch: &sea_orm_arrow::arrow::array::RecordBatch) -> Result<Vec<Self>, DbErr> {
539539
use crate::{IdenStatic, Iterable, with_arrow::arrow_array_to_value};
540540

541541
let num_rows = batch.num_rows();
@@ -602,12 +602,12 @@ pub trait ActiveModelTrait: Clone + Debug {
602602
#[cfg(feature = "with-arrow")]
603603
fn to_arrow(
604604
models: &[Self],
605-
schema: &arrow::datatypes::Schema,
606-
) -> Result<arrow::array::RecordBatch, DbErr> {
605+
schema: &sea_orm_arrow::arrow::datatypes::Schema,
606+
) -> Result<sea_orm_arrow::arrow::array::RecordBatch, DbErr> {
607607
use crate::{Iterable, with_arrow::option_values_to_arrow_array};
608608
use std::sync::Arc;
609609

610-
let mut columns: Vec<Arc<dyn arrow::array::Array>> =
610+
let mut columns: Vec<Arc<dyn sea_orm_arrow::arrow::array::Array>> =
611611
Vec::with_capacity(schema.fields().len());
612612

613613
for field in schema.fields() {
@@ -630,12 +630,13 @@ pub trait ActiveModelTrait: Clone + Debug {
630630
columns.push(array);
631631
} else {
632632
// Field in schema but not in entity → null column
633-
let array = arrow::array::new_null_array(field.data_type(), models.len());
633+
let array =
634+
sea_orm_arrow::arrow::array::new_null_array(field.data_type(), models.len());
634635
columns.push(array);
635636
}
636637
}
637638

638-
arrow::array::RecordBatch::try_new(Arc::new(schema.clone()), columns)
639+
sea_orm_arrow::arrow::array::RecordBatch::try_new(Arc::new(schema.clone()), columns)
639640
.map_err(|e| DbErr::Type(format!("Failed to create RecordBatch: {e}")))
640641
}
641642

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/// Trait for Entities with Arrow integration
22
pub trait ArrowSchema {
33
/// Get the Arrow schema for this Entity
4-
fn arrow_schema() -> arrow::datatypes::Schema;
4+
fn arrow_schema() -> sea_orm_arrow::arrow::datatypes::Schema;
55
}

sea-orm-sync/src/entity/with_arrow.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::DbErr;
2-
use arrow::array::Array;
2+
use sea_orm_arrow::arrow::array::Array;
33
use sea_query::{ColumnType, Value};
44

55
pub use sea_orm_arrow::ArrowError;
@@ -33,7 +33,7 @@ pub(crate) fn is_datetime_column(col_type: &ColumnType) -> bool {
3333

3434
pub(crate) fn option_values_to_arrow_array(
3535
values: &[Option<Value>],
36-
data_type: &arrow::datatypes::DataType,
36+
data_type: &sea_orm_arrow::arrow::datatypes::DataType,
3737
) -> Result<std::sync::Arc<dyn Array>, DbErr> {
3838
sea_orm_arrow::option_values_to_arrow_array(values, data_type).map_err(Into::into)
3939
}

sea-orm-sync/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,7 @@ pub use sea_orm_macros::EnumIter;
749749
pub use strum;
750750

751751
#[cfg(feature = "with-arrow")]
752-
pub use arrow;
752+
pub use sea_orm_arrow::arrow;
753753

754754
#[cfg(feature = "sqlx-dep")]
755755
pub use sqlx;

src/entity/active_model.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ pub trait ActiveModelTrait: Clone + Debug {
543543
/// are attempted first. If the model uses time-crate types, the conversion
544544
/// automatically falls back to the time-crate representation.
545545
#[cfg(feature = "with-arrow")]
546-
fn from_arrow(batch: &arrow::array::RecordBatch) -> Result<Vec<Self>, DbErr> {
546+
fn from_arrow(batch: &sea_orm_arrow::arrow::array::RecordBatch) -> Result<Vec<Self>, DbErr> {
547547
use crate::{IdenStatic, Iterable, with_arrow::arrow_array_to_value};
548548

549549
let num_rows = batch.num_rows();
@@ -610,12 +610,12 @@ pub trait ActiveModelTrait: Clone + Debug {
610610
#[cfg(feature = "with-arrow")]
611611
fn to_arrow(
612612
models: &[Self],
613-
schema: &arrow::datatypes::Schema,
614-
) -> Result<arrow::array::RecordBatch, DbErr> {
613+
schema: &sea_orm_arrow::arrow::datatypes::Schema,
614+
) -> Result<sea_orm_arrow::arrow::array::RecordBatch, DbErr> {
615615
use crate::{Iterable, with_arrow::option_values_to_arrow_array};
616616
use std::sync::Arc;
617617

618-
let mut columns: Vec<Arc<dyn arrow::array::Array>> =
618+
let mut columns: Vec<Arc<dyn sea_orm_arrow::arrow::array::Array>> =
619619
Vec::with_capacity(schema.fields().len());
620620

621621
for field in schema.fields() {
@@ -638,12 +638,13 @@ pub trait ActiveModelTrait: Clone + Debug {
638638
columns.push(array);
639639
} else {
640640
// Field in schema but not in entity → null column
641-
let array = arrow::array::new_null_array(field.data_type(), models.len());
641+
let array =
642+
sea_orm_arrow::arrow::array::new_null_array(field.data_type(), models.len());
642643
columns.push(array);
643644
}
644645
}
645646

646-
arrow::array::RecordBatch::try_new(Arc::new(schema.clone()), columns)
647+
sea_orm_arrow::arrow::array::RecordBatch::try_new(Arc::new(schema.clone()), columns)
647648
.map_err(|e| DbErr::Type(format!("Failed to create RecordBatch: {e}")))
648649
}
649650

src/entity/arrow_schema.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/// Trait for Entities with Arrow integration
22
pub trait ArrowSchema {
33
/// Get the Arrow schema for this Entity
4-
fn arrow_schema() -> arrow::datatypes::Schema;
4+
fn arrow_schema() -> sea_orm_arrow::arrow::datatypes::Schema;
55
}

src/entity/with_arrow.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub(crate) fn is_datetime_column(col_type: &ColumnType) -> bool {
3333

3434
pub(crate) fn option_values_to_arrow_array(
3535
values: &[Option<Value>],
36-
data_type: &arrow::datatypes::DataType,
36+
data_type: &sea_orm_arrow::arrow::datatypes::DataType,
3737
) -> Result<std::sync::Arc<dyn Array>, DbErr> {
3838
sea_orm_arrow::option_values_to_arrow_array(values, data_type).map_err(Into::into)
3939
}

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,7 @@ pub use sea_orm_macros::EnumIter;
749749
pub use strum;
750750

751751
#[cfg(feature = "with-arrow")]
752-
pub use arrow;
752+
pub use sea_orm_arrow::arrow;
753753

754754
#[cfg(feature = "sqlx-dep")]
755755
pub use sqlx;

0 commit comments

Comments
 (0)