From 5cf8a8fb3d0a8f9801e41f103fcfde338ae3ff57 Mon Sep 17 00:00:00 2001 From: Matt Topol Date: Wed, 11 Oct 2023 11:16:59 -0400 Subject: [PATCH] some updates from comments --- go.sum | 2 -- table/metadata.go | 10 +++++----- table/metadata_test.go | 4 ++-- table/snapshots_test.go | 12 ++++++------ 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/go.sum b/go.sum index fe1e9a8..6e1fc0f 100644 --- a/go.sum +++ b/go.sum @@ -70,8 +70,6 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/wolfeidau/s3iofs v1.3.0 h1:O6lf4HCZVuHMjCdMYrpQIfKzLDYbO5BtNrH5RdQGv4c= github.com/wolfeidau/s3iofs v1.3.0/go.mod h1:oWH749wXNok7pJ+5MK7mi5uyS7GqQzeGApEGwUSaIjc= -golang.org/x/exp v0.0.0-20230811145659-89c5cff77bcb h1:mIKbk8weKhSeLH2GmUTrvx8CjkyJmnU1wFmg59CUjFA= -golang.org/x/exp v0.0.0-20230811145659-89c5cff77bcb/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI= golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo= golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8= diff --git a/table/metadata.go b/table/metadata.go index 893d062..957e163 100644 --- a/table/metadata.go +++ b/table/metadata.go @@ -45,10 +45,10 @@ type Metadata interface { // the table was last updated. Each table metadata file should update this // field just before writing. LastUpdatedMillis() int64 - // LastColumn returns the highest assigned column ID for the table. + // LastColumnID returns the highest assigned column ID for the table. // This is used to ensure fields are always assigned an unused ID when // evolving schemas. - LastColumn() int + LastColumnID() int // Schemas returns the list of schemas, stored as objects with their // schema-id. Schemas() []*iceberg.Schema @@ -140,7 +140,7 @@ type commonMetadata struct { UUID uuid.UUID `json:"table-uuid"` Loc string `json:"location"` LastUpdatedMS int64 `json:"last-updated-ms"` - LastColumnID int `json:"last-column-id"` + LastColumnId int `json:"last-column-id"` SchemaList []*iceberg.Schema `json:"schemas"` CurrentSchemaID int `json:"current-schema-id"` Specs []iceberg.PartitionSpec `json:"partition-specs"` @@ -159,7 +159,7 @@ type commonMetadata struct { func (c *commonMetadata) TableUUID() uuid.UUID { return c.UUID } func (c *commonMetadata) Location() string { return c.Loc } func (c *commonMetadata) LastUpdatedMillis() int64 { return c.LastUpdatedMS } -func (c *commonMetadata) LastColumn() int { return c.LastColumnID } +func (c *commonMetadata) LastColumnID() int { return c.LastColumnId } func (c *commonMetadata) Schemas() []*iceberg.Schema { return c.SchemaList } func (c *commonMetadata) CurrentSchema() *iceberg.Schema { for _, s := range c.SchemaList { @@ -314,7 +314,7 @@ func (c *commonMetadata) validate() error { case c.LastUpdatedMS == 0: // last-updated-ms is required return fmt.Errorf("%w: missing last-updated-ms", ErrInvalidMetadata) - case c.LastColumnID == 0: + case c.LastColumnId == 0: // last-column-id is required return fmt.Errorf("%w: missing last-column-id", ErrInvalidMetadata) } diff --git a/table/metadata_test.go b/table/metadata_test.go index 6547baa..080688f 100644 --- a/table/metadata_test.go +++ b/table/metadata_test.go @@ -122,7 +122,7 @@ func TestMetadataV1Parsing(t *testing.T) { assert.Equal(t, uuid.MustParse("d20125c8-7284-442c-9aea-15fee620737c"), meta.TableUUID()) assert.Equal(t, "s3://bucket/test/location", meta.Location()) assert.Equal(t, int64(1602638573874), meta.LastUpdatedMillis()) - assert.Equal(t, 3, meta.LastColumn()) + assert.Equal(t, 3, meta.LastColumnID()) expected := iceberg.NewSchema( 0, @@ -169,7 +169,7 @@ func TestMetadataV2Parsing(t *testing.T) { assert.Equal(t, "s3://bucket/test/location", data.Location()) assert.Equal(t, 34, data.LastSequenceNumber) assert.Equal(t, int64(1602638573590), data.LastUpdatedMS) - assert.Equal(t, 3, data.LastColumnID) + assert.Equal(t, 3, data.LastColumnId) assert.Equal(t, 0, data.SchemaList[0].ID) assert.Equal(t, 1, data.CurrentSchemaID) assert.Equal(t, 0, data.Specs[0].ID()) diff --git a/table/snapshots_test.go b/table/snapshots_test.go index f79f977..6a101a5 100644 --- a/table/snapshots_test.go +++ b/table/snapshots_test.go @@ -26,7 +26,7 @@ import ( "github.com/stretchr/testify/require" ) -func testSnapshot() table.Snapshot { +func Snapshot() table.Snapshot { parentID := int64(19) manifest, schemaid := "s3:/a/b/c.avro", 3 return table.Snapshot{ @@ -42,7 +42,7 @@ func testSnapshot() table.Snapshot { } } -func testSnapshotWithProperties() table.Snapshot { +func SnapshotWithProperties() table.Snapshot { parentID := int64(19) manifest, schemaid := "s3:/a/b/c.avro", 3 return table.Snapshot{ @@ -60,7 +60,7 @@ func testSnapshotWithProperties() table.Snapshot { } func TestSerializeSnapshot(t *testing.T) { - snapshot := testSnapshot() + snapshot := Snapshot() data, err := json.Marshal(snapshot) require.NoError(t, err) @@ -76,7 +76,7 @@ func TestSerializeSnapshot(t *testing.T) { } func TestSerializeSnapshotWithProps(t *testing.T) { - snapshot := testSnapshotWithProperties() + snapshot := SnapshotWithProperties() data, err := json.Marshal(snapshot) require.NoError(t, err) @@ -105,11 +105,11 @@ func TestInvalidOperation(t *testing.T) { } func TestSnapshotString(t *testing.T) { - snapshot := testSnapshot() + snapshot := Snapshot() assert.Equal(t, `append: id=25, parent_id=19, schema_id=3, sequence_number=200, timestamp_ms=1602638573590, manifest_list=s3:/a/b/c.avro`, snapshot.String()) - snapshot = testSnapshotWithProperties() + snapshot = SnapshotWithProperties() assert.Equal(t, `append, {"foo":"bar"}: id=25, parent_id=19, schema_id=3, sequence_number=200, timestamp_ms=1602638573590, manifest_list=s3:/a/b/c.avro`, snapshot.String()) }