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

refactor(rust): Refactor Schema to use generic struct from new polars-schema crate #18539

Merged
merged 5 commits into from
Sep 4, 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
13 changes: 13 additions & 0 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ flate2 = { version = "1", default-features = false }
futures = "0.3.25"
hashbrown = { version = "0.14", features = ["rayon", "ahash", "serde"] }
hex = "0.4.3"
indexmap = { version = "2", features = ["std"] }
indexmap = { version = "2", features = ["std", "serde"] }
itoa = "1.0.6"
itoap = { version = "1", features = ["simd"] }
libc = "0.2"
Expand Down Expand Up @@ -112,6 +112,7 @@ polars-pipe = { version = "0.42.0", path = "crates/polars-pipe", default-feature
polars-plan = { version = "0.42.0", path = "crates/polars-plan", default-features = false }
polars-python = { version = "0.42.0", path = "crates/polars-python", default-features = false }
polars-row = { version = "0.42.0", path = "crates/polars-row", default-features = false }
polars-schema = { version = "0.42.0", path = "crates/polars-schema", default-features = false }
polars-sql = { version = "0.42.0", path = "crates/polars-sql", default-features = false }
polars-stream = { version = "0.42.0", path = "crates/polars-stream", default-features = false }
polars-time = { version = "0.42.0", path = "crates/polars-time", default-features = false }
Expand Down
3 changes: 2 additions & 1 deletion crates/polars-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ description = "Core of the Polars DataFrame library"
polars-compute = { workspace = true }
polars-error = { workspace = true }
polars-row = { workspace = true }
polars-schema = { workspace = true }
polars-utils = { workspace = true }

ahash = { workspace = true }
Expand Down Expand Up @@ -116,7 +117,7 @@ dtype-struct = []
bigidx = ["arrow/bigidx", "polars-utils/bigidx"]
python = []

serde = ["dep:serde", "bitflags/serde"]
serde = ["dep:serde", "bitflags/serde", "polars-schema/serde"]
serde-lazy = ["serde", "arrow/serde", "indexmap/serde", "chrono/serde"]

docs-selection = [
Expand Down
6 changes: 6 additions & 0 deletions crates/polars-core/src/datatypes/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ pub struct Field {
pub dtype: DataType,
}

impl From<Field> for (PlSmallStr, DataType) {
fn from(value: Field) -> Self {
(value.name, value.dtype)
}
}

pub type FieldRef = Arc<Field>;

impl Field {
Expand Down
5 changes: 4 additions & 1 deletion crates/polars-core/src/frame/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,10 @@ impl DataFrame {
/// # Ok::<(), PolarsError>(())
/// ```
pub fn schema(&self) -> Schema {
self.columns.as_slice().into()
self.columns
.iter()
.map(|x| (x.name().clone(), x.dtype().clone()))
.collect()
}

/// Get a reference to the [`DataFrame`] columns.
Expand Down
Loading
Loading