zeroshade commented on code in PR #658:
URL: https://github.com/apache/iceberg-go/pull/658#discussion_r2641331157
##########
manifest_test.go:
##########
@@ -462,7 +462,7 @@ var (
NestedField{ID: 16, Name: "improvement_surcharge", Type:
PrimitiveTypes.Float64, Required: false},
NestedField{ID: 17, Name: "total_amount", Type:
PrimitiveTypes.Float64, Required: true},
NestedField{ID: 18, Name: "congestion_surcharge", Type:
PrimitiveTypes.Float64, Required: false},
- NestedField{ID: 19, Name: "VendorID", Type:
PrimitiveTypes.Int32, Required: false},
+ NestedField{ID: 19, Name: "vendor_id_alt", Type:
PrimitiveTypes.Int32, Required: false},
Review Comment:
why change the field name? Isn't this intended to test the case of multiple
fields with the same name but different IDs?
##########
schema.go:
##########
@@ -809,8 +814,12 @@ type indexByName struct {
func (i *indexByName) ByID() map[int]string {
idToName := make(map[int]string)
- for k, v := range i.index {
- idToName[v] = k
+ for name, id := range i.index {
+ if existingName, ok := idToName[id]; ok && existingName != name
{
+ panic(fmt.Errorf("%w: multiple fields for id %d: %s and
%s",
+ ErrInvalidSchema, id, existingName, name))
+ }
+ idToName[id] = name
}
Review Comment:
I prefer that we forbid duplicate IDs in the first place so that we don't
need to have this check at all
--
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]