Xuanwo commented on code in PR #19:
URL: https://github.com/apache/iceberg-rust/pull/19#discussion_r1281764299


##########
crates/iceberg/src/spec/datatypes.rs:
##########
@@ -305,6 +325,52 @@ pub struct StructField {
     pub write_default: Option<String>,
 }
 
+impl StructField {
+    /// Construct a required field.
+    pub fn required(id: i32, name: impl ToString, field_type: Type) -> Self {
+        Self {
+            id,
+            name: name.to_string(),
+            required: true,
+            field_type,
+            doc: None,
+            initial_default: None,
+            write_default: None,
+        }
+    }
+
+    /// Construct an optional field.
+    pub fn optional(id: i32, name: impl ToString, field_type: Type) -> Self {
+        Self {
+            id,
+            name: name.to_string(),
+            required: false,
+            field_type,
+            doc: None,
+            initial_default: None,
+            write_default: None,
+        }
+    }
+
+    /// Set the field's doc.
+    pub fn with_doc(mut self, doc: impl ToString) -> Self {
+        self.doc = Some(doc.to_string());
+        self
+    }
+
+    /// Set the field's initial default value.
+    pub fn with_initial_default(mut self, value: impl ToString) -> Self {
+        self.initial_default = Some(value.to_string());
+        self
+    }
+
+    /// Set the field's initial default value.
+    pub fn with_write_default(mut self, value: impl ToString) -> Self {

Review Comment:
   write_default and initial_default seems should be a `value`?



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