Fokko commented on code in PR #29:
URL: https://github.com/apache/iceberg-rust/pull/29#discussion_r1296994540


##########
crates/iceberg/src/spec/datatypes.rs:
##########
@@ -354,17 +358,65 @@ pub struct NestedField {
     /// Optional or required
     pub required: bool,
     /// Datatype
-    #[serde(rename = "type")]
     pub field_type: Box<Type>,
     /// Fields may have an optional comment or doc string.
-    #[serde(skip_serializing_if = "Option::is_none")]
     pub doc: Option<String>,
     /// Used to populate the field’s value for all records that were written 
before the field was added to the schema
-    #[serde(skip_serializing_if = "Option::is_none")]
-    pub initial_default: Option<String>,
+    pub initial_default: Option<Literal>,
     /// Used to populate the field’s value for any records written after the 
field was added to the schema, if the writer does not supply the field’s value
+    pub write_default: Option<Literal>,
+}
+
+#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clone)]
+#[serde(rename_all = "kebab-case")]
+struct SerdeNestedField {
+    pub id: i32,
+    pub name: String,
+    pub required: bool,
+    #[serde(rename = "type")]
+    pub field_type: Box<Type>,
     #[serde(skip_serializing_if = "Option::is_none")]
-    pub write_default: Option<String>,
+    pub doc: Option<String>,
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub initial_default: Option<JsonValue>,
+    #[serde(skip_serializing_if = "Option::is_none")]
+    pub write_default: Option<JsonValue>,
+}
+
+impl From<SerdeNestedField> for NestedField {
+    fn from(value: SerdeNestedField) -> Self {
+        NestedField {
+            id: value.id,
+            name: value.name,
+            required: value.required,
+            initial_default: value.initial_default.and_then(|x| {

Review Comment:
   This is the right way to do it. The `initial-default` will be introduced 
with spec v3, but we can define them for classes that are shared across values.



-- 
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