diff --git a/table/metadata.go b/table/metadata.go index 3892d82..893d062 100644 --- a/table/metadata.go +++ b/table/metadata.go @@ -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. @@ -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"` @@ -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 { diff --git a/table/metadata_test.go b/table/metadata_test.go index 46f10f9..e8dac51 100644 --- a/table/metadata_test.go +++ b/table/metadata_test.go @@ -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( @@ -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) @@ -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) diff --git a/table/snapshots.go b/table/snapshots.go index b60d3e5..c539c84 100644 --- a/table/snapshots.go +++ b/table/snapshots.go @@ -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"` @@ -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"` } diff --git a/table/table.go b/table/table.go index be8b3ec..80b68b3 100644 --- a/table/table.go +++ b/table/table.go @@ -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) } diff --git a/table/table_test.go b/table/table_test.go index 429fe0c..cde94ab 100644 --- a/table/table_test.go +++ b/table/table_test.go @@ -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