mattfaltyn opened a new issue, #1791:
URL: https://github.com/apache/iceberg-go/issues/1791
### Apache Iceberg version
main (development), reproduced at
`a56ca68bdf56bbf3181506cbb9a7cb2de482e0e2`; also reproducible in v0.6.0.
### Please describe the bug 🐞
`PartitionField.UnmarshalJSON` intentionally accepts a historical
source-less `void` partition tombstone and represents its omitted source as
`SourceIDs: []int{0}`. However, `PartitionSpec.BindToSchema` rebuilds every
field through `AddPartitionFieldBySourceID`. That attempts to resolve synthetic
source ID 0 in the current schema and rejects the same spec that the metadata
parser accepted.
This breaks operations that rebind or rebuild an accepted partition spec,
including `MetadataBuilder.AddPartitionSpec` and partition evolution paths.
Minimal reproduction:
```go
package main
import (
"encoding/json"
"fmt"
iceberg "github.com/apache/iceberg-go"
)
func main() {
schema := iceberg.NewSchema(1, iceberg.NestedField{
ID: 1, Name: "id", Type: iceberg.PrimitiveTypes.Int64,
Required: true,
})
for _, raw := range []string{
`{"spec-id":0,"fields":[{"field-id":1000,"name":"old_partition","transform":"void"}]}`,
`{"spec-id":0,"fields":[{"source-id":1,"field-id":1000,"name":"old_partition","transform":"void"}]}`,
} {
var spec iceberg.PartitionSpec
parseErr := json.Unmarshal([]byte(raw), &spec)
_, bindErr := spec.BindToSchema(schema, nil, nil)
fmt.Printf("parse=%v bind=%v\n", parseErr, bindErr)
}
}
```
Actual output:
```text
parse=<nil> bind=invalid partition spec: cannot find source column with id:
0 in schema
parse=<nil> bind=<nil>
```
Expected: both accepted specs bind successfully. The source-less `void`
field should retain its field ID, name, and transform without trying to resolve
synthetic source ID 0 against the schema. Explicit `source-id: 0` and
source-less non-`void` fields must remain invalid.
Likely fix: preserve implicit source-less `void` fields directly when
rebuilding a spec, while continuing to bind ordinary fields through the schema.
The same invariant should hold in `UpdateSpec.Apply`, which also reconstructs
existing fields by source ID.
Regression coverage should include:
- source-less `void` parse → `BindToSchema`, with a normal sourced `void`
control;
- partition evolution that retains a source-less tombstone while changing an
unrelated field;
- preservation of spec ID, partition field ID, name, and transform;
- continued rejection of explicit zero source IDs and source-less non-`void`
transforms.
Related history: #1674 noted this as a separate pre-existing bug but
intentionally did not fix it. #1664/#1665 concern explicit ordinal source ID 0
in unbound create-table requests, which is a different path.
### Contribution
I would like to work on this after maintainer acknowledgement.
--
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]