Skip to content

Commit a2d2f85

Browse files
committed
move column, dfschema, etc. to common module
1 parent 2e535f9 commit a2d2f85

File tree

7 files changed

+1986
-1952
lines changed

7 files changed

+1986
-1952
lines changed

datafusion-common/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,4 @@ parquet = { version = "8.0.0", features = ["arrow"] }
4242
avro-rs = { version = "0.13", features = ["snappy"], optional = true }
4343
pyo3 = { version = "0.15", optional = true }
4444
sqlparser = "0.13"
45+
ordered-float = "2.10"

datafusion-common/src/error.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@ use arrow::error::ArrowError;
2626
#[cfg(feature = "avro")]
2727
use avro_rs::Error as AvroError;
2828
use parquet::errors::ParquetError;
29-
#[cfg(feature = "pyarrow")]
30-
use pyo3::exceptions::PyException;
31-
#[cfg(feature = "pyarrow")]
32-
use pyo3::prelude::PyErr;
3329
use sqlparser::parser::ParserError;
3430

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

90-
#[cfg(feature = "pyarrow")]
91-
impl From<DataFusionError> for PyErr {
92-
fn from(err: DataFusionError) -> PyErr {
93-
PyException::new_err(err.to_string())
94-
}
95-
}
96-
9786
impl From<DataFusionError> for ArrowError {
9887
fn from(e: DataFusionError) -> Self {
9988
match e {

datafusion-common/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@
1818
mod column;
1919
mod dfschema;
2020
mod error;
21+
#[cfg(feature = "pyarrow")]
22+
mod pyarrow;
23+
mod scalar;
2124

2225
pub use column::Column;
2326
pub use dfschema::{DFField, DFSchema, DFSchemaRef, ExprSchema, ToDFSchema};
2427
pub use error::{DataFusionError, Result};
28+
pub use scalar::{
29+
ScalarType, ScalarValue, MAX_PRECISION_FOR_DECIMAL128, MAX_SCALE_FOR_DECIMAL128,
30+
};

datafusion/src/pyarrow.rs renamed to datafusion-common/src/pyarrow.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,21 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18-
use pyo3::prelude::*;
18+
//! PyArrow
19+
20+
use crate::{DataFusionError, ScalarValue};
21+
use arrow::array::ArrayData;
22+
use arrow::pyarrow::PyArrowConvert;
23+
use pyo3::exceptions::PyException;
24+
use pyo3::prelude::PyErr;
1925
use pyo3::types::PyList;
26+
use pyo3::{FromPyObject, IntoPy, PyAny, PyObject, PyResult, Python};
2027

21-
use crate::arrow::array::ArrayData;
22-
use crate::arrow::pyarrow::PyArrowConvert;
23-
use crate::scalar::ScalarValue;
28+
impl From<DataFusionError> for PyErr {
29+
fn from(err: DataFusionError) -> PyErr {
30+
PyException::new_err(err.to_string())
31+
}
32+
}
2433

2534
impl PyArrowConvert for ScalarValue {
2635
fn from_pyarrow(value: &PyAny) -> PyResult<Self> {
@@ -68,7 +77,6 @@ mod tests {
6877
use pyo3::prepare_freethreaded_python;
6978
use pyo3::py_run;
7079
use pyo3::types::PyDict;
71-
use pyo3::Python;
7280

7381
fn init_python() {
7482
prepare_freethreaded_python();

0 commit comments

Comments
 (0)