liurenjie1024 commented on code in PR #46:
URL: https://github.com/apache/iceberg-rust/pull/46#discussion_r1308731149


##########
crates/iceberg/src/spec/schema.rs:
##########
@@ -643,6 +655,27 @@ pub(super) mod _serde {
         pub fields: StructType,
     }
 
+    /// Helper to serialize/deserializa Schema
+    impl TryFrom<SchemaEnum> for Schema {
+        type Error = Error;
+        fn try_from(value: SchemaEnum) -> Result<Self> {
+            match value {
+                SchemaEnum::V2(value) => value.try_into(),
+                SchemaEnum::V1(value) => value.try_into(),
+            }
+        }
+    }
+
+    impl From<Schema> for SchemaEnum {
+        fn from(value: Schema) -> Self {
+            if value.schema_id == 0 {

Review Comment:
   Since the only difference between v1 and v2 for schema is `schema_id`, I 
think we should always convert to V2 since this is compatible with both 
formats. Using `schema_id == 0` may be incorrect since 0 maybe a valid schema  
id .



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