zeroshade commented on code in PR #332: URL: https://github.com/apache/iceberg-go/pull/332#discussion_r1997687200
########## manifest.go: ########## @@ -593,42 +624,29 @@ func ReadManifestList(in io.Reader) ([]ManifestFile, error) { return nil, err } - var fallbackAddedSnapshot bool - for _, f := range sc.(*avro.RecordSchema).Fields() { - if f.Name() == "added_snapshot_id" { - if f.Type().Type() == avro.Union { - fallbackAddedSnapshot = true - } - - break - } + version, err := strconv.Atoi(string(dec.Metadata()["format-version"])) + if err != nil { + return nil, fmt.Errorf("invalid format-version: %w", err) } - out := make([]ManifestFile, 0) - for dec.HasNext() { - var file ManifestFile - if string(dec.Metadata()["format-version"]) == "2" { - file = &manifestFileV2{} - } else { - if fallbackAddedSnapshot { - file = &fallbackManifestFileV1{} - } else { - file = &manifestFileV1{} - } - } - - if err := dec.Decode(file); err != nil { - return nil, err - } + if version == 1 { + for _, f := range sc.(*avro.RecordSchema).Fields() { + if f.Name() == "added_snapshot_id" { + if f.Type().Type() == avro.Union { + return decodeManifestsWithFallback[*fallbackManifestFileV1](dec) + } Review Comment: I have to double check but I think this gets tested via the integration tests. -- 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-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org