zeroshade commented on code in PR #2655:
URL: https://github.com/apache/iceberg-go/pull/2655#discussion_r4645657554


##########
types.go:
##########
@@ -475,28 +477,29 @@ func (s *StructType) Equals(other Type) bool {
                return false
        }
 
-       return slices.EqualFunc(s.FieldList, st.FieldList, func(a, b 
NestedField) bool {
+       return slices.EqualFunc(s.fields, st.fields, func(a, b NestedField) 
bool {
                return a.Equals(b)
        })
 }
 
 // NumFields returns the number of fields in the struct.
-func (s *StructType) NumFields() int { return len(s.FieldList) }
+func (s *StructType) NumFields() int { return len(s.fields) }
 
 // Field returns the i-th field of the struct. It panics if i is out of range.
-func (s *StructType) Field(i int) NestedField { return s.FieldList[i] }
+func (s *StructType) Field(i int) NestedField { return s.fields[i] }
 
 // Fields returns a copy of the struct's fields. Changing the returned slice
 // does not change the struct. Use NumFields and Field to read the fields
 // without copying them.
-func (s *StructType) Fields() []NestedField { return slices.Clone(s.FieldList) 
}
+func (s *StructType) Fields() []NestedField { return slices.Clone(s.fields) }
 
 // The JSON methods of the nested types name every serialized field instead of
 // encoding through an alias of the type, so the wire format does not depend on
-// which Go fields are exported.
+// which Go fields are exported. MarshalJSON has a value receiver so values,
+// such as the result of [Schema.AsStruct], encode the same way as pointers.
 
-func (s *StructType) MarshalJSON() ([]byte, error) {
-       fields := s.FieldList
+func (s StructType) MarshalJSON() ([]byte, error) {

Review Comment:
   nit: the value receiver here, next to pointer receivers on every other 
method, is easy for a future "make receivers consistent" cleanup to revert. A 
short note on each of the three `MarshalJSON` methods would guard against that, 
e.g.:
   
   ```go
   // Value receiver on purpose: Schema.AsStruct returns a StructType value,
   // which must not encode as {}.
   ```



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