You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "ryanworl (via GitHub)" <gi...@apache.org> on 2026/08/11 18:44:19 UTC
[PR] fix(manifest): infer manifest list version from the embedded writer schema [iceberg-go]
ryanworl opened a new pull request, #1762:
URL: https://github.com/apache/iceberg-go/pull/1762
Fixes #1760
## What
`ReadManifestList` selected its Avro reader schema solely from the `format-version` file-metadata key, assuming v1 when the key is absent. Per the spec that key is required only for [manifest files](https://iceberg.apache.org/spec/#manifests); for [manifest lists](https://iceberg.apache.org/spec/#manifest-lists) it is optional, and real writers (DuckDB's iceberg extension ≤ 1.5.4) omit it. Reading a keyless v2/v3 list through the v1 reader schema made Avro schema resolution silently drop every writer field the v1 schema doesn't declare: `content` (field-id 517) read as 0 so delete manifests became invisible as deletes, `sequence_number` (515) / `min_sequence_number` (516) read as 0, and v3 `first_row_id` (520) was lost — with no error. Any read-modify-rewrite path (compaction, snapshot expiry, manifest rewriting) would persist that corruption.
## How
Field-ID inference from the embedded writer schema, feeding the existing v1/v2+ decode paths:
- Inside the reader-schema callback, the writer schema's top-level fields are inspected: `content` (517) or `sequence_number` (515) imply v2+, `first_row_id` (520) implies v3, neither means v1. Fields are discriminated primarily by their `field-id` prop — the stable contract per the spec (DuckDB embeds them) — with the spec field names as a fallback for writers that don't annotate IDs.
- Key absent: the inferred version is used. A genuine keyless v1 list still reads as v1 (existing behavior, now pinned by a test).
- Key present and consistent: unchanged behavior.
- Key present but claiming v1 for a schema that carries v2+ fields: an error is returned instead of silently dropping writer fields.
This matches how Java's `ManifestLists.read` and PyIceberg handle these files: they never consult the key and let field-ID resolution against the embedded writer schema decide what is present. The alternative design discussed in the issue — a Java-style single superset reader schema (v2+/v3 fields optional, defaulted in code) with no version branch at all — would also work and is arguably closer to Java; I went with inference as the smaller diff that feeds the existing v1/v2+ code paths. Happy to rework toward the superset approach if maintainers prefer it.
## Tests
- Key-stripped v2 and v3 round-trips: written with `WriteManifestList` containing a delete-content manifest with non-zero sequence numbers (and an assigned `first_row_id` for v3), `format-version` stripped from the OCF header (data blocks byte-identical), read back asserting `content`, `sequence_number`, `min_sequence_number`, and `first_row_id` survive.
- Keyless v1 list still decodes as v1, identical to the same list with the key.
- Key claiming v1 over a v2/v3 schema returns an error.
- A real DuckDB-written fixture (`testdata/duckdb_v3_manifest_list.avro`, 1.7 KB): produced by DuckDB v1.5.4's iceberg extension against a REST catalog — `format-version = '3'` table, one INSERT, one DELETE — and checked in. Under the previous fallback its delete manifest read as a data manifest with zeroed sequence numbers.
`go test ./...` and `golangci-lint run` pass; the fixture is listed in `dev/release/rat_exclude_files.txt` alongside the existing binary test files.
Made with [Cursor](https://cursor.com)
--
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-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] fix(manifest): infer manifest list version from the embedded writer schema [iceberg-go]
Posted by "tanmayrauth (via GitHub)" <gi...@apache.org>.
tanmayrauth commented on code in PR #1762:
URL: https://github.com/apache/iceberg-go/pull/1762#discussion_r3763686860
##########
manifest.go:
##########
@@ -1023,6 +1072,10 @@ func ReadManifestList(in io.Reader) ([]ManifestFile, error) {
}
if version == 1 {
Review Comment:
`if version == 1 { if inferred > 1 { ... } }` - This only half-satisfies the "key present must agree with the schema, error beats zeroed values" rule from the issue. It catches a key claiming v1 over a v2+ schema, but not a key claiming a *lower v2+* version than the schema carries: a file with key="2" but a v3 schema (first_row_id present, inferred 3) reads with version=2 and no error. first_row_id is read into the struct, but Version() reports 2, so a read-modify-rewrite through WriteManifestList(2, …) uses the v2 writer schema and silently drops v3 row lineage — the same corruption this PR fixes, one version up. No real writer emits a key that undershoots its schema today (DuckDB omits the key; Java/Py write consistent keys), so it's adversarial rather than a field bug — but it's cheap to close the whole class: generalize the check to `if version < inferred { return error }`, and add a key=2/schema=v3 case to TestReadManifestListKeyContradictsSchema.
--
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-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] fix(manifest): infer manifest list version from the embedded writer schema [iceberg-go]
Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade merged PR #1762:
URL: https://github.com/apache/iceberg-go/pull/1762
--
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-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] fix(manifest): infer manifest list version from the embedded writer schema [iceberg-go]
Posted by "ryanworl (via GitHub)" <gi...@apache.org>.
ryanworl commented on code in PR #1762:
URL: https://github.com/apache/iceberg-go/pull/1762#discussion_r3766147483
##########
manifest.go:
##########
@@ -999,17 +999,66 @@ func ReadManifest(m ManifestFile, f io.Reader, discardDeleted bool) ([]ManifestE
return results, nil
}
+// Manifest-list entry field IDs used to infer the format version from an
+// embedded writer schema. Per the Iceberg spec, content and sequence_number
+// are required fields for v2+ manifest lists and first_row_id is a v3 field;
+// none of them exist in v1.
+const (
+ fieldIDManifestSequenceNumber = 515
+ fieldIDManifestContent = 517
+ fieldIDManifestFirstRowID = 520
+)
+
+// schemaFieldID returns the Iceberg "field-id" property of an Avro schema
+// field, if present. Props hold decoded JSON, so numbers arrive as float64.
+func schemaFieldID(f avro.SchemaField) (int, bool) {
+ if id, ok := f.Props["field-id"].(float64); ok {
Review Comment:
Done in 88d1401 — schemaFieldID now mirrors the sibling switch (int and float64), and the partition-field reader at the other site calls the same helper so the two can't drift.
##########
manifest.go:
##########
@@ -1023,6 +1072,10 @@ func ReadManifestList(in io.Reader) ([]ManifestFile, error) {
}
if version == 1 {
Review Comment:
Done in 88d1401 — generalized to `version < inferred` with the error message naming both versions, and added the key=2/v3-schema case to TestReadManifestListKeyContradictsSchema.
--
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-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] fix(manifest): infer manifest list version from the embedded writer schema [iceberg-go]
Posted by "tanmayrauth (via GitHub)" <gi...@apache.org>.
tanmayrauth commented on code in PR #1762:
URL: https://github.com/apache/iceberg-go/pull/1762#discussion_r3763686860
##########
manifest.go:
##########
@@ -1023,6 +1072,10 @@ func ReadManifestList(in io.Reader) ([]ManifestFile, error) {
}
if version == 1 {
Review Comment:
`if version == 1 { if inferred > 1 { ... } }` — this only half-satisfies the "key present must agree with the schema, error beats zeroed values" rule from the issue. It catches a key claiming v1 over a v2+ schema, but not a key claiming a *lower v2+* version than the schema carries: a file with key="2" but a v3 schema (first_row_id present, inferred 3) reads with version=2 and no error. first_row_id is read into the struct, but Version() reports 2, so a read-modify-rewrite through WriteManifestList(2, …) uses the v2 writer schema and silently drops v3 row lineage — the same corruption this PR fixes, one version up. No real writer emits a key that undershoots its schema today (DuckDB omits the key; Java/Py write consistent keys), so it's adversarial rather than a field bug — but it's cheap to close the whole class: generalize the check to `if version < inferred { return error }`, and add a key=2/schema=v3 case to TestReadManifestListKeyContradictsSchema.
##########
manifest.go:
##########
@@ -999,17 +999,66 @@ func ReadManifest(m ManifestFile, f io.Reader, discardDeleted bool) ([]ManifestE
return results, nil
}
+// Manifest-list entry field IDs used to infer the format version from an
+// embedded writer schema. Per the Iceberg spec, content and sequence_number
+// are required fields for v2+ manifest lists and first_row_id is a v3 field;
+// none of them exist in v1.
+const (
+ fieldIDManifestSequenceNumber = 515
+ fieldIDManifestContent = 517
+ fieldIDManifestFirstRowID = 520
+)
+
+// schemaFieldID returns the Iceberg "field-id" property of an Avro schema
+// field, if present. Props hold decoded JSON, so numbers arrive as float64.
+func schemaFieldID(f avro.SchemaField) (int, bool) {
+ if id, ok := f.Props["field-id"].(float64); ok {
Review Comment:
`if id, ok := f.Props["field-id"].(float64); ok {` — the name fallback here answers the open question from the issue (writers that don't annotate ids), and it's the right call to keep since DuckDB does embed
them, so it's just belt-and-suspenders. One robustness gap though: this only accepts `float64`, while the existing field-id reader in this same file (`manifest.go:476`, `switch v := field.Props["field-id"].(type)`) handles both `int` and `float64`. For the read path here the writer schema is JSON-parsed from the OCF header, so numbers come through as `float64` and the DuckDB fixture proves it works — no live bug. But the two field-id readers now disagree on accepted types, and that sibling `int` case exists because an in-memory-built schema yields `int` props. If inference is ever handed such a schema, `schemaFieldID` returns false and silently degrades to name-matching, and a writer that annotates only field-ids (non-spec names) then misfires back to the v1 fallback this PR removes. Worth mirroring the sibling type switch to accept `int` too — ideally one shared helper both sites call so they can't drift again.
--
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-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] fix(manifest): infer manifest list version from the embedded writer schema [iceberg-go]
Posted by "tanmayrauth (via GitHub)" <gi...@apache.org>.
tanmayrauth commented on code in PR #1762:
URL: https://github.com/apache/iceberg-go/pull/1762#discussion_r3763682824
##########
manifest.go:
##########
@@ -999,17 +999,66 @@ func ReadManifest(m ManifestFile, f io.Reader, discardDeleted bool) ([]ManifestE
return results, nil
}
+// Manifest-list entry field IDs used to infer the format version from an
+// embedded writer schema. Per the Iceberg spec, content and sequence_number
+// are required fields for v2+ manifest lists and first_row_id is a v3 field;
+// none of them exist in v1.
+const (
+ fieldIDManifestSequenceNumber = 515
+ fieldIDManifestContent = 517
+ fieldIDManifestFirstRowID = 520
+)
+
+// schemaFieldID returns the Iceberg "field-id" property of an Avro schema
+// field, if present. Props hold decoded JSON, so numbers arrive as float64.
+func schemaFieldID(f avro.SchemaField) (int, bool) {
+ if id, ok := f.Props["field-id"].(float64); ok {
Review Comment:
The name fallback here answers the open question from the issue (writers that don't annotate ids), and it's the right call to keep since DuckDB does embed them, so it's just belt-and-suspenders. One robustness gap though: this only accepts `float64`, while the existing field-id reader in this same file (`manifest.go:476`, `switch v := field.Props["field-id"].(type)`) handles both `int` and `float64`. For the read path here the writer schema is JSON-parsed from the OCF header, so numbers come through as `float64` and the DuckDB fixture proves it works — no live bug. But the two field-id readers now disagree on accepted types, and that sibling `int` case exists because an in-memory-built schema yields `int` props. If inference is ever handed such a schema, `schemaFieldID` returns false and silently degrades to name-matching, and a writer that annotates only field-ids (non-spec names) then misfires back to the v1 fallback this PR removes. Worth mirroring the sibling type switch
to accept `int` too — ideally one shared helper both sites call so they can't drift again.
##########
manifest.go:
##########
@@ -1023,6 +1072,10 @@ func ReadManifestList(in io.Reader) ([]ManifestFile, error) {
}
if version == 1 {
Review Comment:
This only half-satisfies the "key present must agree with the schema, error beats zeroed values" rule from the issue. It catches a key claiming v1 over a v2+ schema, but not a key claiming a *lower v2+* version than the schema carries: a file with key="2" but a v3 schema (first_row_id present, inferred 3) reads with version=2 and no error. first_row_id is read into the struct, but Version() reports 2, so a read-modify-rewrite through WriteManifestList(2, …) uses the v2 writer schema and silently drops v3 row lineage — the same corruption this PR fixes, one version up. No real writer emits a key that undershoots its schema today (DuckDB omits the key; Java/Py write consistent keys), so it's adversarial rather than a field bug — but it's cheap to close the whole class: generalize the check to `if version < inferred { return error }`, and add a key=2/schema=v3 case to TestReadManifestListKeyContradictsSchema.
--
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-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] fix(manifest): infer manifest list version from the embedded writer schema [iceberg-go]
Posted by "tanmayrauth (via GitHub)" <gi...@apache.org>.
tanmayrauth commented on code in PR #1762:
URL: https://github.com/apache/iceberg-go/pull/1762#discussion_r3763682824
##########
manifest.go:
##########
@@ -999,17 +999,66 @@ func ReadManifest(m ManifestFile, f io.Reader, discardDeleted bool) ([]ManifestE
return results, nil
}
+// Manifest-list entry field IDs used to infer the format version from an
+// embedded writer schema. Per the Iceberg spec, content and sequence_number
+// are required fields for v2+ manifest lists and first_row_id is a v3 field;
+// none of them exist in v1.
+const (
+ fieldIDManifestSequenceNumber = 515
+ fieldIDManifestContent = 517
+ fieldIDManifestFirstRowID = 520
+)
+
+// schemaFieldID returns the Iceberg "field-id" property of an Avro schema
+// field, if present. Props hold decoded JSON, so numbers arrive as float64.
+func schemaFieldID(f avro.SchemaField) (int, bool) {
+ if id, ok := f.Props["field-id"].(float64); ok {
Review Comment:
The name fallback here answers the open question from the issue (writers that don't annotate ids), and it's the right call to keep since DuckDB does embed
them, so it's just belt-and-suspenders. One robustness gap though: this only accepts `float64`, while the existing field-id reader in this same file (`manifest.go:476`, `switch v := field.Props["field-id"].(type)`) handles both `int` and `float64`. For the read path here the writer schema is JSON-parsed from the OCF header, so numbers come through as `float64` and the DuckDB fixture proves it works — no live bug. But the two field-id readers now disagree on accepted types, and that sibling `int` case exists because an in-memory-built schema yields `int` props. If inference is ever handed such a schema, `schemaFieldID` returns false and silently degrades to name-matching, and a writer that annotates only field-ids (non-spec names) then misfires back to the v1 fallback this PR removes. Worth mirroring the sibling type switch to accept `int` too — ideally one shared helper both sites call so they can't drift again.
--
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-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org