ShivamSharma43 opened a new pull request, #2628:
URL: https://github.com/apache/iceberg-go/pull/2628

   On a v3 table with a struct, list or map column that has a `write-default`, 
every `UpdateSchema` failed, even one that only adds or renames another column:
   
   ```
   error applying schema changes: error encountered during schema visitor: 
runtime error: comparing uncomparable type map[string]interface {}
   ```
   
   The spec allows these defaults. A struct column's default is stored as `{}` 
([spec](https://github.com/apache/iceberg/blob/52fc764127402ade8170b1b53ddd95fde13cb75c/format/spec.md?plain=1#L389-L391)),
 and list and map defaults are a JSON array and a JSON object. iceberg-go loads 
such metadata (`validateComplexDefault` accepts these shapes) and keeps the 
defaults as `map[string]any` and `[]any`.
   
   ### Cause
   
   `applyChanges.Struct` decided whether a field changed with 
`field.WriteDefault == writeDefault`. Both are `any`, and `==` panics when both 
hold the same map or slice type. `iceberg.Visit` recovers the panic and returns 
it as the error above. The comparison runs for every field of every struct in 
the schema, so one such column blocked all schema changes on the table.
   
   ### Fix
   
   Compare the write defaults with `reflect.DeepEqual`, as `NestedField.Equals` 
and `unionUpdateColumn` already do. Java's 
[`ApplyChanges.struct`](https://github.com/apache/iceberg/blob/52fc764127402ade8170b1b53ddd95fde13cb75c/core/src/main/java/org/apache/iceberg/SchemaUpdate.java#L623-L652)
 compares the old and new field with `equals`.
   
   ### Testing
   
   - New `TestUpdateSchemaWithNestedTypeWriteDefault` loads a v3 schema whose 
struct (`{}`), list (`[]`) or map (`{"keys":[],"values":[]}`) column has a 
write default, then adds a column and renames another in one `Commit`. It 
checks that both changes are applied and that the nested column's write default 
is unchanged. All three cases fail on main with the error above.
   - `go vet ./table/` and `golangci-lint run ./table/` (v2.14.0) are clean. 
`go test ./table/...` passes except for tests that fail the same way on 
unmodified main on my Windows machine (path handling): 
`TestEmptyStringIdentityPartitionScans`, `TestScanImportedSignedZeroBounds`, 
`TestDeleteImportedSignedZerosWithIn`, 
`TestDeleteNormallyWrittenSignedZeroWithIn`, 
`TestScanLegacyEmptyStringPartitionDeleteBounds`, 
`TestScanWithIDLessNameMappingFields`, two 
`TestRewriteDataFiles_PartialProgress*` tests, `TestWriteMapType` and 
`TestGetReferencedFiles_OverwriteThenExpireExcludesTombstones`.
   
   Closes #2627
   
   This PR was prepared with AI assistance (Claude Code).
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


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