Repository navigation
feat(table): Table Metadata V3 support - #585
Conversation
| func initMetadataV3Deser() *metadataV3 { | ||
| return &metadataV3{ | ||
| LastSeqNum: -1, | ||
| NextRowIDValue: 0, |
There was a problem hiding this comment.
should we also init this to -1? if we init to 0, we cannot tell if it was sent or not, 0 is a valid value, missing is not according to the spec
There was a problem hiding this comment.
Yes I think you are right about this. I have updated the PR to reflect this
| func (m *metadataV3) checkLastSequenceNumber() error { | ||
| for _, snap := range m.SnapshotList { | ||
| if snap.SequenceNumber > m.LastSequenceNumber() { | ||
| return fmt.Errorf("%w: snapshot %d has sequence number %d which is greater than last-sequence-number %d", | ||
| ErrInvalidMetadata, snap.SnapshotID, snap.SequenceNumber, m.LastSequenceNumber()) | ||
| } | ||
| } | ||
|
|
||
| return nil | ||
| } |
There was a problem hiding this comment.
Is there a way to not have this function twice? maybe by defining another interface which defines a func LastSequenceNumber() and implements this which would be part of both metadata v2 & v3?
| func (b *MetadataBuilder) SetNextRowID(nextRowID int64) *MetadataBuilder { | ||
| b.nextRowID = &nextRowID | ||
| return b | ||
| } |
There was a problem hiding this comment.
do we need a setter here? On what occasion would we want to set this from the outside?
It probably makes sense to not expose this to library users. My current understanding is that we only need to increment this in AddSnapshot based on the number of added rows in the snapshot.
There was a problem hiding this comment.
looking at iceberg-java, there's only a write to nextRowId in Builder::addSnapshot which does:
this.nextRowId += snapshot.addedRows();other assignments are either carryover from base metadata to builder or initial assignment to initial row id.
There was a problem hiding this comment.
I'm in agreement here, we shouldn't have this setter
There was a problem hiding this comment.
Yes you both are spot on about this 😄
| if m.NextRowIDValue == -1 { | ||
| return 0 // RFor v1/v2 compatibility when field is missing | ||
| } | ||
| return m.NextRowIDValue |
There was a problem hiding this comment.
| if m.NextRowIDValue == -1 { | |
| return 0 // RFor v1/v2 compatibility when field is missing | |
| } | |
| return m.NextRowIDValue | |
| return max(0, m.NextRowIDValue) |
maybe?
| if m.NextRowIDValue == -1 { | ||
| return fmt.Errorf("%w: next-row-id is required for v3 tables", ErrInvalidMetadata) | ||
| } | ||
| if m.NextRowIDValue < -1 { | ||
| return fmt.Errorf("%w: next-row-id must be non-negative, got %d", ErrInvalidMetadata, m.NextRowIDValue) | ||
| } |
There was a problem hiding this comment.
this feels like it could be rolled into the same check or otherwise avoid needing two checks
Signed-off-by: dttung2905 <[email protected]>
Signed-off-by: dttung2905 <[email protected]>
Signed-off-by: dttung2905 <[email protected]>
Signed-off-by: dttung2905 <[email protected]>
0207ed3 to
44cd158
Compare
|
Thanks @zeroshade . I see this. NewMetadataBuilder() require an int as introduced by a recent commit. I just rebased from main 🙏 |

List of changes implemented
NextRowIDfield tocommonMetadataFirstRowIDfield toSnapshotstruct