zeroshade commented on code in PR #580:
URL: https://github.com/apache/iceberg-go/pull/580#discussion_r2393860056
##########
table/metadata.go:
##########
@@ -183,28 +184,37 @@ type MetadataBuilder struct {
lastAddedSortOrderID *int
}
-func NewMetadataBuilder() (*MetadataBuilder, error) {
+func NewMetadataBuilder(formatVersion int) (*MetadataBuilder, error) {
Review Comment:
we should probably error if an invalid format version is passed (i.e. one we
don't support)
##########
table/metadata.go:
##########
@@ -183,28 +184,37 @@ type MetadataBuilder struct {
lastAddedSortOrderID *int
}
-func NewMetadataBuilder() (*MetadataBuilder, error) {
+func NewMetadataBuilder(formatVersion int) (*MetadataBuilder, error) {
return &MetadataBuilder{
- updates: make([]Update, 0),
- schemaList: make([]*iceberg.Schema, 0),
- specs: make([]iceberg.PartitionSpec, 0),
- props: make(iceberg.Properties),
- snapshotList: make([]Snapshot, 0),
- snapshotLog: make([]SnapshotLogEntry, 0),
- metadataLog: make([]MetadataLogEntry, 0),
- sortOrderList: make([]SortOrder, 0),
- refs: make(map[string]SnapshotRef),
+ updates: make([]Update, 0),
+ schemaList: make([]*iceberg.Schema, 0),
+ specs: make([]iceberg.PartitionSpec, 0),
+ props: make(iceberg.Properties),
+ snapshotList: make([]Snapshot, 0),
+ snapshotLog: make([]SnapshotLogEntry, 0),
+ metadataLog: make([]MetadataLogEntry, 0),
+ sortOrderList: make([]SortOrder, 0),
+ refs: make(map[string]SnapshotRef),
+ currentSchemaID: -1,
+ defaultSortOrderID: -1,
+ defaultSpecID: -1,
+ lastColumnId: -1,
+ formatVersion: formatVersion,
}, nil
}
-func MetadataBuilderFromBase(metadata Metadata) (*MetadataBuilder, error) {
+// MetadataBuilderFromBase creates a MetadataBuilder from an existing Metadata
object.
+// currentFileLocation is the location where the current version of the
metadata
+// file is stored. This is used to update the metadata log. If
currentFileLocation is
+// empty, the metadata log will not be updated. This should only be used to
stage-create tables.
+func MetadataBuilderFromBase(metadata Metadata, currentFileLocation string)
(*MetadataBuilder, error) {
b := &MetadataBuilder{}
b.base = metadata
b.formatVersion = metadata.Version()
b.uuid = metadata.TableUUID()
b.loc = metadata.Location()
- b.lastUpdatedMS = metadata.LastUpdatedMillis()
+ b.lastUpdatedMS = 0
Review Comment:
what's the reasoning for this change?
##########
table/metadata.go:
##########
@@ -183,28 +184,37 @@ type MetadataBuilder struct {
lastAddedSortOrderID *int
}
-func NewMetadataBuilder() (*MetadataBuilder, error) {
+func NewMetadataBuilder(formatVersion int) (*MetadataBuilder, error) {
return &MetadataBuilder{
- updates: make([]Update, 0),
- schemaList: make([]*iceberg.Schema, 0),
- specs: make([]iceberg.PartitionSpec, 0),
- props: make(iceberg.Properties),
- snapshotList: make([]Snapshot, 0),
- snapshotLog: make([]SnapshotLogEntry, 0),
- metadataLog: make([]MetadataLogEntry, 0),
- sortOrderList: make([]SortOrder, 0),
- refs: make(map[string]SnapshotRef),
+ updates: make([]Update, 0),
+ schemaList: make([]*iceberg.Schema, 0),
+ specs: make([]iceberg.PartitionSpec, 0),
+ props: make(iceberg.Properties),
+ snapshotList: make([]Snapshot, 0),
+ snapshotLog: make([]SnapshotLogEntry, 0),
+ metadataLog: make([]MetadataLogEntry, 0),
+ sortOrderList: make([]SortOrder, 0),
+ refs: make(map[string]SnapshotRef),
+ currentSchemaID: -1,
+ defaultSortOrderID: -1,
+ defaultSpecID: -1,
+ lastColumnId: -1,
+ formatVersion: formatVersion,
}, nil
}
-func MetadataBuilderFromBase(metadata Metadata) (*MetadataBuilder, error) {
+// MetadataBuilderFromBase creates a MetadataBuilder from an existing Metadata
object.
+// currentFileLocation is the location where the current version of the
metadata
+// file is stored. This is used to update the metadata log. If
currentFileLocation is
+// empty, the metadata log will not be updated. This should only be used to
stage-create tables.
+func MetadataBuilderFromBase(metadata Metadata, currentFileLocation string)
(*MetadataBuilder, error) {
Review Comment:
would it make more sense to just add a member to the `Metadata` that is the
current location it was read from instead of adding the new parameter here?
--
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]