Skip to content

Commit

Permalink
some updates from comments
Browse files Browse the repository at this point in the history
  • Loading branch information
zeroshade committed Oct 11, 2023
1 parent a4e6037 commit 5cf8a8f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
10 changes: 5 additions & 5 deletions table/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"`
Expand All @@ -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 {
Expand Down Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions table/metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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())
Expand Down
12 changes: 6 additions & 6 deletions table/snapshots_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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{
Expand All @@ -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)

Expand All @@ -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)

Expand Down Expand Up @@ -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())
}

0 comments on commit 5cf8a8f

Please sign in to comment.