ZENOTME commented on code in PR #406:
URL: https://github.com/apache/iceberg-rust/pull/406#discussion_r1641888209
##########
crates/iceberg/src/spec/values.rs:
##########
@@ -105,6 +108,115 @@ pub struct Datum {
literal: PrimitiveLiteral,
}
+impl Serialize for Datum {
+ fn serialize<S: serde::Serializer>(
+ &self,
+ serializer: S,
+ ) -> std::result::Result<S::Ok, S::Error> {
+ let mut strucet_ser = serializer
+ .serialize_struct("Datum", 2)
+ .map_err(serde::ser::Error::custom)?;
+ strucet_ser
+ .serialize_field("type", &self.r#type)
+ .map_err(serde::ser::Error::custom)?;
+ strucet_ser
+ .serialize_field(
+ "literal",
+ &RawLiteral::try_from(
Review Comment:
But we need the type info to convert to/from RawLiteral. For serialize in
PrimitiveLiteral, we don't need the type info. But for deserialize, even in
PrimitiveLiteral, we need the type info. e.g.
https://github.com/apache/iceberg-rust/blob/7f286b56031b1ed9a9fb7d18aeb83abd736e44c4/crates/iceberg/src/spec/values.rs#L2440.
That's why we can't implement Ser/De for Literal directly.
--
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]