Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[split/4] move scalar value to datafusion-common #1760

Merged
merged 1 commit into from
Feb 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions datafusion-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@ parquet = { version = "8.0.0", features = ["arrow"] }
avro-rs = { version = "0.13", features = ["snappy"], optional = true }
pyo3 = { version = "0.15", optional = true }
sqlparser = "0.13"
ordered-float = "2.10"
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
6 changes: 6 additions & 0 deletions datafusion-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@
mod column;
mod dfschema;
mod error;
#[cfg(feature = "pyarrow")]
mod pyarrow;
mod scalar;

pub use column::Column;
pub use dfschema::{DFField, DFSchema, DFSchemaRef, ExprSchema, ToDFSchema};
pub use error::{DataFusionError, Result};
pub use scalar::{
ScalarType, ScalarValue, MAX_PRECISION_FOR_DECIMAL128, MAX_SCALE_FOR_DECIMAL128,
};
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
Loading