twuebi commented on code in PR #580:
URL: https://github.com/apache/iceberg-go/pull/580#discussion_r2394494641


##########
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:
   it's java & rust behavior, the if condition in Build() checks if 
b.lastUpdatedMS == 0 and only then updates it to Now(), according to spec, it 
should always be updated to Now():
   
   <img width="742" height="151" alt="image" 
src="https://github.com/user-attachments/assets/c5d48bfc-9bf5-42a0-8850-187206eeeed3";
 />
   



-- 
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]

Reply via email to