From a543b73e45f212f210f4c97c8e3e31f3b1ee3be5 Mon Sep 17 00:00:00 2001 From: Kuba Valtar Date: Tue, 29 Jul 2025 15:13:49 +0200 Subject: [PATCH] chore: Remove `deserialize_with_unknown_fields` --- Cargo.lock | 10 ---- Cargo.toml | 1 - crates/polars-plan/Cargo.toml | 2 +- crates/polars-utils/Cargo.toml | 2 - crates/polars-utils/src/pl_serialize.rs | 70 ------------------------- 5 files changed, 1 insertion(+), 84 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cf7fd74aa6f6..e582edfec628 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3679,7 +3679,6 @@ dependencies = [ "rmp-serde", "schemars", "serde", - "serde_ignored", "serde_json", "slotmap", "stacker", @@ -4628,15 +4627,6 @@ dependencies = [ "syn 2.0.104", ] -[[package]] -name = "serde_ignored" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b516445dac1e3535b6d658a7b528d771153dfb272ed4180ca4617a20550365ff" -dependencies = [ - "serde", -] - [[package]] name = "serde_json" version = "1.0.140" diff --git a/Cargo.toml b/Cargo.toml index 8c4a0c5bd0c4..4e9b23d3938a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -79,7 +79,6 @@ rmp-serde = "1.3" ryu = "1.0.13" schemars = { version = "0.8.22", features = ["preserve_order"] } serde = { version = "1.0.188", features = ["derive", "rc"] } -serde_ignored = "0.1.12" serde_json = "1" sha2 = "0.10" simd-json = { version = "0.15", features = ["known-key"] } diff --git a/crates/polars-plan/Cargo.toml b/crates/polars-plan/Cargo.toml index 92bd6fc767f3..766be7fa5a34 100644 --- a/crates/polars-plan/Cargo.toml +++ b/crates/polars-plan/Cargo.toml @@ -211,7 +211,7 @@ allow_unused = ["polars-io/allow_unused", "polars-ops/allow_unused", "polars-tim bigidx = ["polars-core/bigidx", "polars-utils/bigidx"] polars_cloud_client = ["serde"] -polars_cloud_server = ["serde", "polars-utils/polars_cloud_server"] +polars_cloud_server = ["serde"] ir_serde = ["serde", "polars-utils/ir_serde"] [package.metadata.docs.rs] diff --git a/crates/polars-utils/Cargo.toml b/crates/polars-utils/Cargo.toml index c20ce01d89bc..b719c7545a2c 100644 --- a/crates/polars-utils/Cargo.toml +++ b/crates/polars-utils/Cargo.toml @@ -29,7 +29,6 @@ regex = { workspace = true } rmp-serde = { workspace = true, optional = true } schemars = { workspace = true, optional = true } serde = { workspace = true, optional = true } -serde_ignored = { workspace = true, optional = true } serde_json = { workspace = true, optional = true } slotmap = { workspace = true } stacker = { workspace = true } @@ -57,7 +56,6 @@ serde = [ "uuid/serde", ] dsl-schema = ["dep:schemars"] -polars_cloud_server = ["dep:serde_ignored"] python = ["pyo3", "polars-error/python"] [lints] diff --git a/crates/polars-utils/src/pl_serialize.rs b/crates/polars-utils/src/pl_serialize.rs index 1c2066637ef3..f5fbcc8e6fc7 100644 --- a/crates/polars-utils/src/pl_serialize.rs +++ b/crates/polars-utils/src/pl_serialize.rs @@ -38,21 +38,6 @@ where } } -#[cfg(feature = "polars_cloud_server")] -/// Deserializes the value and collects paths to all unknown fields. -fn deserialize_with_unknown_fields(reader: R) -> PolarsResult<(T, Vec)> -where - T: serde::de::DeserializeOwned, - R: std::io::Read, -{ - let mut de = rmp_serde::Deserializer::new(reader); - let mut unknown_fields = Vec::new(); - let t = serde_ignored::deserialize(&mut de, |path| { - unknown_fields.push(path.to_string()); - }); - t.map(|t| (t, unknown_fields)).map_err(to_compute_err) -} - /// Mainly used to enable compression when serializing the final outer value. /// For intermediate serialization steps, the function in the module should /// be used instead. @@ -95,25 +80,6 @@ impl SerializeOptions { } } - /// Deserializes the value and collects paths to all unknown fields. - /// - /// Supports only the future-compatible format (`FC: true`). - #[cfg(feature = "polars_cloud_server")] - pub fn deserialize_from_reader_with_unknown_fields( - &self, - reader: R, - ) -> PolarsResult<(T, Vec)> - where - T: serde::de::DeserializeOwned, - R: std::io::Read, - { - if self.compression { - deserialize_with_unknown_fields(flate2::read::ZlibDecoder::new(reader)) - } else { - deserialize_with_unknown_fields(reader) - } - } - pub fn serialize_to_bytes(&self, value: &T) -> PolarsResult> where T: serde::ser::Serialize, @@ -327,40 +293,4 @@ mod tests { assert_eq!(r, v); } - - #[cfg(feature = "polars_cloud_server")] - #[test] - fn test_serde_collect_unknown_fields() { - #[derive(Clone, Copy, serde::Serialize)] - struct A { - x: bool, - u: u8, - } - - #[derive(serde::Serialize)] - enum E { - V { val: A, ch: char }, - } - - #[derive(serde::Deserialize)] - struct B { - u: u8, - } - - #[derive(serde::Deserialize)] - enum F { - V { val: B }, - } - - let a = A { u: 42, x: true }; - let e = E::V { val: a, ch: 'x' }; - - let buf: Vec = super::serialize_to_bytes::<_, true>(&e).unwrap(); - let (f, unknown) = super::deserialize_with_unknown_fields::(buf.as_slice()).unwrap(); - - let F::V { val: b } = f; - - assert_eq!(a.u, b.u); - assert_eq!(unknown.as_slice(), &["val.x", "ch"]); - } }