Skip to content

Commit

Permalink
Add arrow conversions for SchemaRef
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Jan 13, 2025
1 parent 9ff456a commit e857670
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/datatypes/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,17 @@ impl From<arrow_schema::Schema> for Schema {
}
}

#[cfg(feature = "arrow")]
impl From<arrow_schema::SchemaRef> for Schema {
fn from(schema: arrow_schema::SchemaRef) -> Self {
let arrow_schema::Schema { fields, metadata } = schema.as_ref();
Self {
fields: fields.iter().map(Into::into).collect(),
metadata: metadata.clone().into_iter().collect(),
}
}
}

#[cfg(feature = "arrow")]
impl From<Schema> for arrow_schema::Schema {
fn from(schema: Schema) -> Self {
Expand All @@ -79,3 +90,12 @@ impl From<Schema> for arrow_schema::Schema {
Self::new_with_metadata(fields, metadata.into_iter().collect())
}
}

impl From<Schema> for arrow_schema::SchemaRef {

Check failure on line 94 in src/datatypes/schema.rs

View workflow job for this annotation

GitHub Actions / cross (wasm32-unknown-unknown)

failed to resolve: use of undeclared crate or module `arrow_schema`
fn from(schema: Schema) -> Self {
let Schema { fields, metadata } = schema;
let fields: arrow_schema::Fields =

Check failure on line 97 in src/datatypes/schema.rs

View workflow job for this annotation

GitHub Actions / cross (wasm32-unknown-unknown)

failed to resolve: use of undeclared crate or module `arrow_schema`
fields.into_iter().map(arrow_schema::Field::from).collect();

Check failure on line 98 in src/datatypes/schema.rs

View workflow job for this annotation

GitHub Actions / cross (wasm32-unknown-unknown)

failed to resolve: use of undeclared crate or module `arrow_schema`
arrow_schema::Schema::new_with_metadata(fields, metadata.into_iter().collect()).into()

Check failure on line 99 in src/datatypes/schema.rs

View workflow job for this annotation

GitHub Actions / cross (wasm32-unknown-unknown)

failed to resolve: use of undeclared crate or module `arrow_schema`
}
}

0 comments on commit e857670

Please sign in to comment.