laskoviymishka commented on code in PR #2641:
URL: https://github.com/apache/iceberg-go/pull/2641#discussion_r4622724376
##########
table/metadata_preflight_test.go:
##########
@@ -147,3 +148,41 @@ func
TestParseMetadataBytesRejectsCaseFoldedFormatVersionCollision(t *testing.T)
_, err := ParseMetadataBytes([]byte(data))
require.ErrorIs(t, err, ErrInvalidMetadataFormatVersion)
}
+
+func TestParseMetadataBytesPreservesTypeErrorOffset(t *testing.T) {
+ for _, version := range []struct {
+ number int
+ target json.Unmarshaler
+ }{
+ {1, &metadataV1{}},
Review Comment:
nit: the inner `spec` table uses keyed literals (`{name: "whitespace"}`), so
`{number: 1, target: &metadataV1{}}` here would read the same way. Optional.
##########
table/metadata_preflight_test.go:
##########
@@ -147,3 +148,41 @@ func
TestParseMetadataBytesRejectsCaseFoldedFormatVersionCollision(t *testing.T)
_, err := ParseMetadataBytes([]byte(data))
require.ErrorIs(t, err, ErrInvalidMetadataFormatVersion)
}
+
+func TestParseMetadataBytesPreservesTypeErrorOffset(t *testing.T) {
+ for _, version := range []struct {
+ number int
+ target json.Unmarshaler
+ }{
+ {1, &metadataV1{}},
+ {2, &metadataV2{}},
+ {3, &metadataV3{}},
+ } {
+ t.Run(fmt.Sprintf("v%d", version.number), func(t *testing.T) {
+ for _, spec := range []struct {
+ name string
+ fields string
+ }{
+ {name: "whitespace"},
+ {name: "normalized", fields:
`,"partition-specs":[{"spec-id":0,"fields":[{"source-id":1,"name":"id","transform":"identity"}]}]`},
+ } {
+ t.Run(spec.name, func(t *testing.T) {
+ input := []byte(fmt.Sprintf("
\t\r\n"+`{"format-version":%d,"last-updated-ms":1,"last-column-id":"not-an-int"%s}`+"\n",
Review Comment:
nit: `fmt.Appendf(nil, ...)` skips the string-to-bytes conversion, and the
package already uses it in tests (`updates_test.go`,
`inspect_partitions_bench_test.go`). Lint doesn't require it either way.
--
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]