Skip to content

Commit

Permalink
Fix schema to_pyarrow_schema to convert datatype using Python
Browse files Browse the repository at this point in the history
  • Loading branch information
Jay Chia committed Sep 9, 2024
1 parent 278fa0b commit 8add10e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/daft-core/src/python/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use serde::{Deserialize, Serialize};
use super::datatype::PyDataType;
use super::field::PyField;
use crate::datatypes;
use crate::ffi::field_to_py;
use crate::schema;
use common_py_serde::impl_bincode_py_state_serialization;

Expand All @@ -29,7 +28,16 @@ impl PySchema {
.schema
.fields
.iter()
.map(|(_, f)| field_to_py(&f.to_arrow()?, py, pyarrow))
.map(|(_, f)| {
// NOTE: Use PyDataType::to_arrow because we need to dip into Python to get
// the registered Arrow extension types
let py_dtype: PyDataType = f.dtype.clone().into();
let py_arrow_dtype = py_dtype.to_arrow(py)?;
pyarrow
.getattr(pyo3::intern!(py, "field"))
.unwrap()
.call1((f.name.clone(), py_arrow_dtype))
})
.collect::<PyResult<Vec<_>>>()?;
pyarrow
.getattr(pyo3::intern!(py, "schema"))
Expand Down

0 comments on commit 8add10e

Please sign in to comment.