badalprasadsingh commented on code in PR #524:
URL: https://github.com/apache/iceberg-go/pull/524#discussion_r2323985507


##########
manifest.go:
##########
@@ -416,30 +429,53 @@ func getFieldIDMap(sc avro.Schema) (map[string]int, 
map[int]avro.LogicalType) {
 
        result := make(map[string]int)
        logicalTypes := make(map[int]avro.LogicalType)
+       fixedSizes := make(map[int]int)
+
        entryField := getField(sc.(*avro.RecordSchema), "data_file")
        partitionField := getField(entryField.Type().(*avro.RecordSchema), 
"partition")
 
        for _, field := range 
partitionField.Type().(*avro.RecordSchema).Fields() {
-               if fid, ok := field.Prop("field-id").(float64); ok {
-                       result[field.Name()] = int(fid)
-                       avroTyp := field.Type()
-                       if us, ok := avroTyp.(*avro.UnionSchema); ok {
-                               for _, t := range us.Types() {
-                                       avroTyp = t
-                               }
+               var fid int
+               switch v := field.Prop("field-id").(type) {
+               case int:
+                       fid = v
+               case int32:
+                       fid = int(v)
+               case int64:
+                       fid = int(v)
+               case float64:
+                       fid = int(v)
+               default:
+                       continue
+               }
+
+               result[field.Name()] = fid
+               avroTyp := field.Type()
+               if us, ok := avroTyp.(*avro.UnionSchema); ok {
+                       for _, t := range us.Types() {
+                               avroTyp = t
                        }

Review Comment:
   we can skip, it is iterating through all types in the `union` and 
reassigning `avroTyp` to each one (effectively ending up with the last type in 
the union which is not a nil type).
   
   further on, `NullSchema` is neither `PrimitiveSchema` nor `FixedSchema`, so 
it gets ignored.



##########
manifest.go:
##########
@@ -416,30 +429,53 @@ func getFieldIDMap(sc avro.Schema) (map[string]int, 
map[int]avro.LogicalType) {
 
        result := make(map[string]int)
        logicalTypes := make(map[int]avro.LogicalType)
+       fixedSizes := make(map[int]int)
+
        entryField := getField(sc.(*avro.RecordSchema), "data_file")
        partitionField := getField(entryField.Type().(*avro.RecordSchema), 
"partition")
 
        for _, field := range 
partitionField.Type().(*avro.RecordSchema).Fields() {
-               if fid, ok := field.Prop("field-id").(float64); ok {
-                       result[field.Name()] = int(fid)
-                       avroTyp := field.Type()
-                       if us, ok := avroTyp.(*avro.UnionSchema); ok {
-                               for _, t := range us.Types() {
-                                       avroTyp = t
-                               }
+               var fid int
+               switch v := field.Prop("field-id").(type) {
+               case int:
+                       fid = v
+               case int32:
+                       fid = int(v)
+               case int64:
+                       fid = int(v)
+               case float64:
+                       fid = int(v)
+               default:
+                       continue
+               }
+
+               result[field.Name()] = fid
+               avroTyp := field.Type()
+               if us, ok := avroTyp.(*avro.UnionSchema); ok {
+                       for _, t := range us.Types() {
+                               avroTyp = t
                        }

Review Comment:
   we can skip, it is iterating through all types in the `union` and 
reassigning `avroTyp` to each one (effectively ending up with the last type in 
the union which is not a null type).
   
   further on, `NullSchema` is neither `PrimitiveSchema` nor `FixedSchema`, so 
it gets ignored.



-- 
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: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to