From d6509063e03dd41443faeb34e6e39febab8fc730 Mon Sep 17 00:00:00 2001 From: Dylan Chen Date: Thu, 8 Jan 2026 17:41:57 +0800 Subject: [PATCH] skip_serializing the partitioin fields from FileScanTask --- crates/iceberg/src/scan/task.rs | 38 ++++++--------------------------- 1 file changed, 7 insertions(+), 31 deletions(-) diff --git a/crates/iceberg/src/scan/task.rs b/crates/iceberg/src/scan/task.rs index fe79c0edcc..eab12e22bd 100644 --- a/crates/iceberg/src/scan/task.rs +++ b/crates/iceberg/src/scan/task.rs @@ -18,7 +18,7 @@ use std::sync::Arc; use futures::stream::BoxStream; -use serde::{Deserialize, Serialize, Serializer}; +use serde::{Deserialize, Serialize}; use crate::Result; use crate::expr::BoundPredicate; @@ -30,24 +30,6 @@ use crate::spec::{ /// A stream of [`FileScanTask`]. pub type FileScanTaskStream = BoxStream<'static, Result>; -/// Serialization helper that always returns NotImplementedError. -/// Used for fields that should not be serialized but we want to be explicit about it. -fn serialize_not_implemented(_: &T, _: S) -> std::result::Result -where S: Serializer { - Err(serde::ser::Error::custom( - "Serialization not implemented for this field", - )) -} - -/// Deserialization helper that always returns NotImplementedError. -/// Used for fields that should not be deserialized but we want to be explicit about it. -fn deserialize_not_implemented<'de, D, T>(_: D) -> std::result::Result -where D: serde::Deserializer<'de> { - Err(serde::de::Error::custom( - "Deserialization not implemented for this field", - )) -} - /// A task to scan part of file. #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] pub struct FileScanTask { @@ -92,28 +74,22 @@ pub struct FileScanTask { /// Partition data from the manifest entry, used to identify which columns can use /// constant values from partition metadata vs. reading from the data file. /// Per the Iceberg spec, only identity-transformed partition fields should use constants. - #[serde(default)] - #[serde(skip_serializing_if = "Option::is_none")] - #[serde(serialize_with = "serialize_not_implemented")] - #[serde(deserialize_with = "deserialize_not_implemented")] + #[serde(skip_serializing)] + #[serde(skip_deserializing)] pub partition: Option, /// The partition spec for this file, used to distinguish identity transforms /// (which use partition metadata constants) from non-identity transforms like /// bucket/truncate (which must read source columns from the data file). - #[serde(default)] - #[serde(skip_serializing_if = "Option::is_none")] - #[serde(serialize_with = "serialize_not_implemented")] - #[serde(deserialize_with = "deserialize_not_implemented")] + #[serde(skip_serializing)] + #[serde(skip_deserializing)] pub partition_spec: Option>, /// Name mapping from table metadata (property: schema.name-mapping.default), /// used to resolve field IDs from column names when Parquet files lack field IDs /// or have field ID conflicts. - #[serde(default)] - #[serde(skip_serializing_if = "Option::is_none")] - #[serde(serialize_with = "serialize_not_implemented")] - #[serde(deserialize_with = "deserialize_not_implemented")] + #[serde(skip_serializing)] + #[serde(skip_deserializing)] pub name_mapping: Option>, }