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

[CHORE] Move out datatype and schema from daft-core #2806

Merged
merged 25 commits into from
Sep 9, 2024
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
42 changes: 40 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ common-hashable-float-wrapper = {path = "src/common/hashable-float-wrapper", def
common-resource-request = {path = "src/common/resource-request", default-features = false}
common-system-info = {path = "src/common/system-info", default-features = false}
common-tracing = {path = "src/common/tracing", default-features = false}
common-version = {path = "src/common/version", default-features = false}
daft-compression = {path = "src/daft-compression", default-features = false}
daft-core = {path = "src/daft-core", default-features = false}
daft-csv = {path = "src/daft-csv", default-features = false}
Expand Down
11 changes: 11 additions & 0 deletions src/common/arrow-ffi/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[dependencies]
arrow2 = {workspace = true}
pyo3 = {workspace = true, optional = true}

[features]
python = ["dep:pyo3"]

[package]
edition = {workspace = true}
name = "common-arrow-ffi"
version = {workspace = true}
7 changes: 6 additions & 1 deletion src/daft-core/src/ffi.rs → src/common/arrow-ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ use std::io::Cursor;

use arrow2::{array::Array, datatypes::Field, ffi};

#[cfg(feature = "python")]
use pyo3::ffi::Py_uintptr_t;
#[cfg(feature = "python")]
use pyo3::prelude::*;

pub type ArrayRef = Box<dyn Array>;

#[cfg(feature = "python")]
pub fn array_to_rust(arrow_array: &PyAny) -> PyResult<ArrayRef> {
// prepare a pointer to receive the Array struct
let array = Box::new(ffi::ArrowArray::empty());
Expand All @@ -28,7 +31,7 @@ pub fn array_to_rust(arrow_array: &PyAny) -> PyResult<ArrayRef> {
Ok(array)
}
}

#[cfg(feature = "python")]
pub fn to_py_array(array: ArrayRef, py: Python, pyarrow: &PyModule) -> PyResult<PyObject> {
let schema = Box::new(ffi::export_field_to_c(&Field::new(
"",
Expand All @@ -53,6 +56,7 @@ pub fn to_py_array(array: ArrayRef, py: Python, pyarrow: &PyModule) -> PyResult<
Ok(array.to_object(py))
}

#[cfg(feature = "python")]
pub fn field_to_py(
field: &arrow2::datatypes::Field,
py: Python,
Expand All @@ -69,6 +73,7 @@ pub fn field_to_py(
Ok(field.to_object(py))
}

#[cfg(feature = "python")]
pub fn dtype_to_py(
dtype: &arrow2::datatypes::DataType,
py: Python,
Expand Down
3 changes: 0 additions & 3 deletions src/common/daft-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
use common_io_config::IOConfig;
use serde::{Deserialize, Serialize};

/// Environment variables for Daft to use when formatting displays.
pub const BOLD_TABLE_HEADERS_IN_DISPLAY: &str = "DAFT_BOLD_TABLE_HEADERS";

/// Configurations for Daft to use during the building of a Dataframe's plan.
///
/// 1. Creation of a Dataframe including any file listing and schema inference that needs to happen. Note
Expand Down
1 change: 1 addition & 0 deletions src/common/display/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[dependencies]
comfy-table = {workspace = true}
indexmap = {workspace = true}
pyo3 = {workspace = true, optional = true}
terminal_size = {version = "0.3.0"}
Expand Down
2 changes: 2 additions & 0 deletions src/common/display/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#![feature(let_chains)]
pub mod ascii;
pub mod mermaid;
pub mod table_display;
pub mod tree;
pub mod utils;

Expand Down
Loading
Loading