Skip to content

Commit

Permalink
updates from feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
zeroshade committed Oct 11, 2023
1 parent 18e544e commit 6023e54
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 23 deletions.
16 changes: 8 additions & 8 deletions table/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ type Metadata interface {
// table is created. Implementations must throw an exception if a table's
// UUID does not match the expected UUID after refreshing metadata.
TableUUID() uuid.UUID
// Loc is the table's base location. This is used by writers to determine
// Location is the table's base location. This is used by writers to determine
// where to store data files, manifest files, and table metadata files.
Loc() string
// LastUpdated is the timestamp in milliseconds from the unix epoch when
Location() string
// LastUpdatedMillis is the timestamp in milliseconds from the unix epoch when
// the table was last updated. Each table metadata file should update this
// field just before writing.
LastUpdated() int
LastUpdatedMillis() int64
// LastColumn returns the highest assigned column ID for the table.
// This is used to ensure fields are always assigned an unused ID when
// evolving schemas.
Expand Down Expand Up @@ -138,8 +138,8 @@ func ParseMetadataBytes(b []byte) (Metadata, error) {
type commonMetadata struct {
FormatVersion int `json:"format-version"`
UUID uuid.UUID `json:"table-uuid"`
Location string `json:"location"`
LastUpdatedMS int `json:"last-updated-ms"`
Loc string `json:"location"`
LastUpdatedMS int64 `json:"last-updated-ms"`
LastColumnID int `json:"last-column-id"`
SchemaList []*iceberg.Schema `json:"schemas"`
CurrentSchemaID int `json:"current-schema-id"`
Expand All @@ -157,8 +157,8 @@ type commonMetadata struct {
}

func (c *commonMetadata) TableUUID() uuid.UUID { return c.UUID }
func (c *commonMetadata) Loc() string { return c.Location }
func (c *commonMetadata) LastUpdated() int { return c.LastUpdatedMS }
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) Schemas() []*iceberg.Schema { return c.SchemaList }
func (c *commonMetadata) CurrentSchema() *iceberg.Schema {
Expand Down
10 changes: 5 additions & 5 deletions table/metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ func TestMetadataV1Parsing(t *testing.T) {

data := meta.(*table.MetadataV1)
assert.Equal(t, uuid.MustParse("d20125c8-7284-442c-9aea-15fee620737c"), meta.TableUUID())
assert.Equal(t, "s3://bucket/test/location", meta.Loc())
assert.Equal(t, 1602638573874, meta.LastUpdated())
assert.Equal(t, "s3://bucket/test/location", meta.Location())
assert.Equal(t, int64(1602638573874), meta.LastUpdatedMillis())
assert.Equal(t, 3, meta.LastColumn())

expected := iceberg.NewSchema(
Expand Down Expand Up @@ -166,9 +166,9 @@ func TestMetadataV2Parsing(t *testing.T) {

data := meta.(*table.MetadataV2)
assert.Equal(t, uuid.MustParse("9c12d441-03fe-4693-9a96-a0705ddf69c1"), data.UUID)
assert.Equal(t, "s3://bucket/test/location", data.Location)
assert.Equal(t, "s3://bucket/test/location", data.Location())
assert.Equal(t, 34, data.LastSequenceNumber)
assert.Equal(t, 1602638573590, data.LastUpdatedMS)
assert.Equal(t, int64(1602638573590), data.LastUpdatedMS)
assert.Equal(t, 3, data.LastColumnID)
assert.Equal(t, 0, data.SchemaList[0].ID)
assert.Equal(t, 1, data.CurrentSchemaID)
Expand All @@ -178,7 +178,7 @@ func TestMetadataV2Parsing(t *testing.T) {
assert.EqualValues(t, "134217728", data.Props["read.split.target.size"])
assert.EqualValues(t, 3055729675574597004, *data.CurrentSnapshotID)
assert.EqualValues(t, 3051729675574597004, data.SnapshotList[0].SnapshotID)
assert.Equal(t, 1515100955770, data.SnapshotLog[0].TimestampMs)
assert.Equal(t, int64(1515100955770), data.SnapshotLog[0].TimestampMs)
assert.Equal(t, 3, data.SortOrderList[0].OrderID)
assert.Equal(t, 3, data.DefaultSortOrderID)

Expand Down
8 changes: 4 additions & 4 deletions table/snapshots.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ func (s *Summary) MarshalJSON() ([]byte, error) {
type Snapshot struct {
SnapshotID int64 `json:"snapshot-id"`
ParentSnapshotID *int64 `json:"parent-snapshot-id,omitempty"`
SequenceNumber int `json:"sequence-number"`
TimestampMs int `json:"timestamp-ms"`
SequenceNumber int64 `json:"sequence-number"`
TimestampMs int64 `json:"timestamp-ms"`
ManifestList string `json:"manifest-list,omitempty"`
Summary *Summary `json:"summary,omitempty"`
SchemaID *int `json:"schema-id,omitempty"`
Expand Down Expand Up @@ -177,10 +177,10 @@ func (s Snapshot) Manifests(fio io.IO) ([]iceberg.ManifestFile, error) {

type MetadataLogEntry struct {
MetadataFile string `json:"metadata-file"`
TimestampMs int `json:"timestamp-ms"`
TimestampMs int64 `json:"timestamp-ms"`
}

type SnapshotLogEntry struct {
SnapshotID int64 `json:"snapshot-id"`
TimestampMs int `json:"timestamp-ms"`
TimestampMs int64 `json:"timestamp-ms"`
}
10 changes: 5 additions & 5 deletions table/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ func (t Table) Equals(other Table) bool {
reflect.DeepEqual(t.metadata, other.metadata)
}

func (t Table) Identifier() Identifier { return t.identifier }
func (t Table) Metadata() Metadata { return t.metadata }
func (t Table) MetadataLoc() string { return t.metadataLocation }
func (t Table) FS() io.IO { return t.fs }
func (t Table) Identifier() Identifier { return t.identifier }
func (t Table) Metadata() Metadata { return t.metadata }
func (t Table) MetadataLocation() string { return t.metadataLocation }
func (t Table) FS() io.IO { return t.fs }

func (t Table) Schema() *iceberg.Schema { return t.metadata.CurrentSchema() }
func (t Table) Spec() iceberg.PartitionSpec { return t.metadata.PartitionSpec() }
func (t Table) SortOrder() SortOrder { return t.metadata.SortOrder() }
func (t Table) Properties() iceberg.Properties { return t.metadata.Properties() }
func (t Table) Location() string { return t.metadata.Loc() }
func (t Table) Location() string { return t.metadata.Location() }
func (t Table) CurrentSnapshot() *Snapshot { return t.metadata.CurrentSnapshot() }
func (t Table) SnapshotByID(id int64) *Snapshot { return t.metadata.SnapshotByID(id) }
func (t Table) SnapshotByName(name string) *Snapshot { return t.metadata.SnapshotByName(name) }
Expand Down
2 changes: 1 addition & 1 deletion table/table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (t *TableTestSuite) SetupSuite() {
t.Require().NotNil(tbl)

t.Equal([]string{"foo"}, tbl.Identifier())
t.Equal("s3://bucket/test/location/uuid.metadata.json", tbl.MetadataLoc())
t.Equal("s3://bucket/test/location/uuid.metadata.json", tbl.MetadataLocation())
t.Equal(&mockfs, tbl.FS())

t.tbl = tbl
Expand Down

0 comments on commit 6023e54

Please sign in to comment.