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


##########
table/metadata.go:
##########
@@ -435,6 +441,42 @@ func (b *MetadataBuilder) AddSnapshot(snapshot *Snapshot) 
error {
        return nil
 }
 
+func (b *MetadataBuilder) validateAndUpdateRowLineage(snapshot *Snapshot) 
error {
+       if b.formatVersion < minFormatVersionRowLineage {
+               return nil
+       }
+
+       if err := snapshot.ValidateRowLineage(); err != nil {
+               return err
+       }
+
+       if snapshot.FirstRowID == nil {
+               return fmt.Errorf("%w: first-row-id is required for v3 
snapshots", ErrInvalidRowLineage)
+       }
+
+       nextRowID := b.currentNextRowID()
+       if *snapshot.FirstRowID < nextRowID {
+               return fmt.Errorf("%w: first-row-id %d is behind table 
next-row-id %d",
+                       ErrInvalidRowLineage, *snapshot.FirstRowID, nextRowID)
+       }
+
+       newNextRowID := nextRowID + *snapshot.AddedRows

Review Comment:
   <img width="1174" height="455" alt="image" 
src="https://github.com/user-attachments/assets/61a26839-1801-4614-bbbc-86f622de84c7";
 />
   



##########
table/metadata.go:
##########
@@ -435,6 +441,42 @@ func (b *MetadataBuilder) AddSnapshot(snapshot *Snapshot) 
error {
        return nil
 }
 
+func (b *MetadataBuilder) validateAndUpdateRowLineage(snapshot *Snapshot) 
error {
+       if b.formatVersion < minFormatVersionRowLineage {
+               return nil
+       }
+
+       if err := snapshot.ValidateRowLineage(); err != nil {
+               return err
+       }
+
+       if snapshot.FirstRowID == nil {
+               return fmt.Errorf("%w: first-row-id is required for v3 
snapshots", ErrInvalidRowLineage)
+       }
+
+       nextRowID := b.currentNextRowID()
+       if *snapshot.FirstRowID < nextRowID {
+               return fmt.Errorf("%w: first-row-id %d is behind table 
next-row-id %d",
+                       ErrInvalidRowLineage, *snapshot.FirstRowID, nextRowID)
+       }
+
+       newNextRowID := nextRowID + *snapshot.AddedRows

Review Comment:
   https://iceberg.apache.org/spec/#snapshots



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