Skip to content

Commit

Permalink
Update for breaking changes in apache/arrow-rs#2711
Browse files Browse the repository at this point in the history
  • Loading branch information
tustvold committed Sep 20, 2022
1 parent 81b5794 commit 9de354b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 7 additions & 0 deletions Cargo.toml
Expand Up @@ -34,3 +34,10 @@ exclude = ["datafusion-cli"]
[profile.release]
codegen-units = 1
lto = true

[patch.crates-io]
arrow = { git = "https://github.com/tustvold/arrow-rs.git", rev = "6f62bb62f630cbd910ae5b1b04f97688af7c1b42" }
parquet = { git = "https://github.com/tustvold/arrow-rs.git", rev = "6f62bb62f630cbd910ae5b1b04f97688af7c1b42" }
arrow-buffer = { git = "https://github.com/tustvold/arrow-rs.git", rev = "6f62bb62f630cbd910ae5b1b04f97688af7c1b42" }
arrow-schema = { git = "https://github.com/tustvold/arrow-rs.git", rev = "6f62bb62f630cbd910ae5b1b04f97688af7c1b42" }
arrow-flight = { git = "https://github.com/tustvold/arrow-rs.git", rev = "6f62bb62f630cbd910ae5b1b04f97688af7c1b42" }
8 changes: 4 additions & 4 deletions datafusion/common/src/pyarrow.rs
Expand Up @@ -19,7 +19,7 @@

use crate::{DataFusionError, ScalarValue};
use arrow::array::ArrayData;
use arrow::pyarrow::PyArrowConvert;
use arrow::pyarrow::{PyArrowConvert, PyArrowType};
use pyo3::exceptions::PyException;
use pyo3::prelude::PyErr;
use pyo3::types::PyList;
Expand All @@ -43,16 +43,16 @@ impl PyArrowConvert for ScalarValue {
let array = factory.call1((args, typ))?;

// convert the pyarrow array to rust array using C data interface
let array = array.extract::<ArrayData>()?;
let scalar = ScalarValue::try_from_array(&array.into(), 0)?;
let array = array.extract::<PyArrowType<ArrayData>>()?;
let scalar = ScalarValue::try_from_array(&array.0.into(), 0)?;

Ok(scalar)
}

fn to_pyarrow(&self, py: Python) -> PyResult<PyObject> {
let array = self.to_array();
// convert to pyarrow array using C data interface
let pyarray = array.data_ref().clone().into_py(py);
let pyarray = PyArrowType(array.data_ref().clone()).into_py(py);
let pyscalar = pyarray.call_method1(py, "__getitem__", (0,))?;

Ok(pyscalar)
Expand Down

0 comments on commit 9de354b

Please sign in to comment.