blackmwk commented on code in PR #3091:
URL: https://github.com/apache/iceberg-rust/pull/3091#discussion_r3879715321


##########
crates/iceberg/src/scan/task.rs:
##########
@@ -18,35 +18,148 @@
 use std::sync::Arc;
 
 use futures::stream::BoxStream;
-use serde::{Deserialize, Serialize, Serializer};
+use serde::{Deserialize, Serialize};
 use typed_builder::TypedBuilder;
 
 use crate::Result;
 use crate::expr::BoundPredicate;
 use crate::spec::{
-    DataContentType, DataFileFormat, ManifestEntryRef, NameMapping, 
PartitionSpec, Schema,
-    SchemaRef, Struct, StructType,
+    DataContentType, DataFileFormat, Literal, ManifestEntryRef, NameMapping, 
PartitionSpec,
+    PrimitiveLiteral, Schema, SchemaRef, Struct, StructType,
 };
 
 /// A stream of [`FileScanTask`].
 pub type FileScanTaskStream = BoxStream<'static, Result<FileScanTask>>;
 
-/// 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<S, T>(_: &T, _: S) -> std::result::Result<S::Ok, 
S::Error>
-where S: Serializer {
-    Err(serde::ser::Error::custom(
-        "Serialization not implemented for this field",
-    ))
-}
+mod partition_serde {

Review Comment:
   Reworked this based on the follow-up discussion:  cannot be deserialized 
without type information, so  now has a private  adapter that uses the existing 
 implementation and reconstructs the partition with the task schema and 
partition spec.



##########
crates/iceberg/src/spec/values/literal.rs:
##########
@@ -55,6 +57,132 @@ pub enum Literal {
     Map(Map),
 }
 
+#[derive(SerializeDerive, DeserializeDerive)]
+#[serde(tag = "type", content = "value", rename_all = "kebab-case")]
+enum SerializableLiteral {
+    Boolean(bool),
+    Int(i32),
+    Long(i64),
+    Float([u8; 4]),
+    Double([u8; 8]),
+    String(String),
+    Binary(Vec<u8>),
+    Int128([u8; 16]),
+    UInt128([u8; 16]),

Review Comment:
   Removed the direct  serde representation (including this enum naming) in 
favor of the typed  conversion inside .



##########
crates/iceberg/src/scan/task.rs:
##########
@@ -282,3 +387,50 @@ pub struct FileScanTaskDeleteFile {
     #[builder(default)]
     pub key_metadata: Option<Box<[u8]>>,
 }
+
+#[cfg(test)]

Review Comment:
   Removed the task-local test module; the regression coverage now lives with 
the existing  serde test in .



##########
crates/iceberg/src/spec/values/literal.rs:
##########
@@ -55,6 +57,132 @@ pub enum Literal {
     Map(Map),
 }
 
+#[derive(SerializeDerive, DeserializeDerive)]
+#[serde(tag = "type", content = "value", rename_all = "kebab-case")]
+enum SerializableLiteral {
+    Boolean(bool),
+    Int(i32),
+    Long(i64),
+    Float([u8; 4]),
+    Double([u8; 8]),
+    String(String),
+    Binary(Vec<u8>),
+    Int128([u8; 16]),
+    UInt128([u8; 16]),

Review Comment:
   Removed the direct Literal serde representation, including this enum naming, 
in favor of the typed RawLiteral conversion inside FileScanTask.



##########
crates/iceberg/src/scan/task.rs:
##########
@@ -18,35 +18,148 @@
 use std::sync::Arc;
 
 use futures::stream::BoxStream;
-use serde::{Deserialize, Serialize, Serializer};
+use serde::{Deserialize, Serialize};
 use typed_builder::TypedBuilder;
 
 use crate::Result;
 use crate::expr::BoundPredicate;
 use crate::spec::{
-    DataContentType, DataFileFormat, ManifestEntryRef, NameMapping, 
PartitionSpec, Schema,
-    SchemaRef, Struct, StructType,
+    DataContentType, DataFileFormat, Literal, ManifestEntryRef, NameMapping, 
PartitionSpec,
+    PrimitiveLiteral, Schema, SchemaRef, Struct, StructType,
 };
 
 /// A stream of [`FileScanTask`].
 pub type FileScanTaskStream = BoxStream<'static, Result<FileScanTask>>;
 
-/// 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<S, T>(_: &T, _: S) -> std::result::Result<S::Ok, 
S::Error>
-where S: Serializer {
-    Err(serde::ser::Error::custom(
-        "Serialization not implemented for this field",
-    ))
-}
+mod partition_serde {

Review Comment:
   Reworked this based on the follow-up discussion: Literal cannot be 
deserialized without type information, so FileScanTask now has a private _serde 
adapter that uses the existing RawLiteral implementation and reconstructs the 
partition with the task schema and partition spec.



##########
crates/iceberg/src/scan/task.rs:
##########
@@ -282,3 +387,50 @@ pub struct FileScanTaskDeleteFile {
     #[builder(default)]
     pub key_metadata: Option<Box<[u8]>>,
 }
+
+#[cfg(test)]

Review Comment:
   Removed the task-local test module; the regression coverage now lives with 
the existing FileScanTask serde test in scan/mod.rs.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to