Skip to content

Commit

Permalink
fix doc test
Browse files Browse the repository at this point in the history
  • Loading branch information
jimexist committed Feb 6, 2022
1 parent 7cbbd5a commit bf73f15
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 20 deletions.
11 changes: 0 additions & 11 deletions datafusion-common/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ use arrow::error::ArrowError;
#[cfg(feature = "avro")]
use avro_rs::Error as AvroError;
use parquet::errors::ParquetError;
#[cfg(feature = "pyarrow")]
use pyo3::exceptions::PyException;
#[cfg(feature = "pyarrow")]
use pyo3::prelude::PyErr;
use sqlparser::parser::ParserError;

/// Result type for operations that could result in an [DataFusionError]
Expand Down Expand Up @@ -87,13 +83,6 @@ impl From<ArrowError> for DataFusionError {
}
}

#[cfg(feature = "pyarrow")]
impl From<DataFusionError> for PyErr {
fn from(err: DataFusionError) -> PyErr {
PyException::new_err(err.to_string())
}
}

impl From<DataFusionError> for ArrowError {
fn from(e: DataFusionError) -> Self {
match e {
Expand Down
2 changes: 2 additions & 0 deletions datafusion-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
mod column;
mod dfschema;
mod error;
#[cfg(feature = "pyarrow")]
mod pyarrow;
mod scalar;

pub use column::Column;
Expand Down
18 changes: 13 additions & 5 deletions datafusion/src/pyarrow.rs → datafusion-common/src/pyarrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,21 @@
// specific language governing permissions and limitations
// under the License.

use pyo3::prelude::*;
//! PyArrow

use crate::{DataFusionError, ScalarValue};
use arrow::array::ArrayData;
use arrow::pyarrow::PyArrowConvert;
use pyo3::exceptions::PyException;
use pyo3::prelude::PyErr;
use pyo3::types::PyList;
use pyo3::{FromPyObject, IntoPy, PyAny, PyObject, PyResult, Python};

use crate::arrow::array::ArrayData;
use crate::arrow::pyarrow::PyArrowConvert;
use crate::scalar::ScalarValue;
impl From<DataFusionError> for PyErr {
fn from(err: DataFusionError) -> PyErr {
PyException::new_err(err.to_string())
}
}

impl PyArrowConvert for ScalarValue {
fn from_pyarrow(value: &PyAny) -> PyResult<Self> {
Expand Down Expand Up @@ -68,7 +77,6 @@ mod tests {
use pyo3::prepare_freethreaded_python;
use pyo3::py_run;
use pyo3::types::PyDict;
use pyo3::Python;

fn init_python() {
prepare_freethreaded_python();
Expand Down
2 changes: 1 addition & 1 deletion datafusion-common/src/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ impl ScalarValue {
///
/// Example
/// ```
/// use datafusion::scalar::ScalarValue;
/// use datafusion_common::ScalarValue;
/// use arrow::array::{ArrayRef, BooleanArray};
///
/// let scalars = vec![
Expand Down
3 changes: 0 additions & 3 deletions datafusion/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,6 @@ pub use parquet;

pub(crate) mod field_util;

#[cfg(feature = "pyarrow")]
mod pyarrow;

pub mod from_slice;

#[cfg(test)]
Expand Down

0 comments on commit bf73f15

Please sign in to comment.