Revanth14 commented on code in PR #1284:
URL: https://github.com/apache/iceberg-go/pull/1284#discussion_r3470783575
##########
schema_test.go:
##########
@@ -1177,6 +1199,47 @@ func TestSchemaWithGeometryGeographyTypes(t *testing.T) {
assert.True(t, schema.Equals(&unmarshaledSchema))
}
+func TestSchemaGeoTypeStringWireFormatFixture(t *testing.T) {
+ fixtureBytes, err := os.ReadFile(filepath.Join("testdata",
geoSchemaJavaFixtureName))
+ require.NoError(t, err, "fixture missing")
+
+ var schema iceberg.Schema
+ require.NoError(t, json.Unmarshal(fixtureBytes, &schema))
+
+ freshBytes, err := json.Marshal(&schema)
+ require.NoError(t, err)
+
+ fixtureTypes := rawTopLevelFieldTypes(t, fixtureBytes)
+ freshTypes := rawTopLevelFieldTypes(t, freshBytes)
+ require.Equal(t, fixtureTypes, freshTypes)
+ assert.Equal(t, `"geometry(srid:3857)"`, freshTypes["geom"])
+ assert.Equal(t, `"geography(srid:4269, karney)"`, freshTypes["geog"])
+ assert.Equal(t, `"geography(srid:4269)"`,
freshTypes["geog_default_algo"])
+ assert.Equal(t, `"geography(OGC:CRS84, karney)"`,
freshTypes["geog_default_crs"])
+}
+
+func rawTopLevelFieldTypes(t *testing.T, data []byte) map[string]string {
+ t.Helper()
+
+ var schema struct {
+ Fields []struct {
+ Name string `json:"name"`
+ Type json.RawMessage `json:"type"`
+ } `json:"fields"`
+ }
+ require.NoError(t, json.Unmarshal(data, &schema))
+ require.NotEmpty(t, schema.Fields)
+
+ types := make(map[string]string, len(schema.Fields))
+ for _, field := range schema.Fields {
+ require.NotEmpty(t, field.Name)
+ require.NotEmptyf(t, field.Type, "field %q is missing type",
field.Name)
Review Comment:
Done. Kept the existing non-empty guard and added an explicit `"null"` check
so a raw JSON null type fails as missing instead of passing as non-empty bytes.
--
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]