Skip to content

Commit 3ce6bbb

Browse files
committed
linter
1 parent faff324 commit 3ce6bbb

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

pyiceberg/table/snapshots.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,12 @@ class Snapshot(IcebergBaseModel):
244244
manifest_list: str = Field(alias="manifest-list", description="Location of the snapshot's manifest list file")
245245
summary: Optional[Summary] = Field(default=None)
246246
schema_id: Optional[int] = Field(alias="schema-id", default=None)
247-
first_row_id: Optional[int] = Field(alias="first-row-id", default=None, description="assigned to the first row in the first data file in the first manifest")
248-
added_rows: Optional[int] = Field(alias="added-rows", default=None, description="Sum of the `added_rows_count` from all manifests added in this snapshot.")
247+
first_row_id: Optional[int] = Field(
248+
alias="first-row-id", default=None, description="assigned to the first row in the first data file in the first manifest"
249+
)
250+
added_rows: Optional[int] = Field(
251+
alias="added-rows", default=None, description="Sum of the `added_rows_count` from all manifests added in this snapshot."
252+
)
249253

250254
def __str__(self) -> str:
251255
"""Return the string representation of the Snapshot class."""

pyiceberg/table/update/__init__.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -434,21 +434,27 @@ def _(update: AddSnapshotUpdate, base_metadata: TableMetadata, context: _TableMe
434434
f"Cannot add snapshot with sequence number {update.snapshot.sequence_number} "
435435
f"older than last sequence number {base_metadata.last_sequence_number}"
436436
)
437-
elif (base_metadata.format_version >= 3 and update.snapshot.first_row_id is None):
437+
elif base_metadata.format_version >= 3 and update.snapshot.first_row_id is None:
438438
raise ValueError("Cannot add snapshot without first row id")
439-
elif (base_metadata.format_version >= 3 and update.snapshot.first_row_id is not None and update.snapshot.first_row_id < base_metadata.next_row_id):
440-
raise ValueError(f"Cannot add a snapshot with first row id smaller than the table's next-row-id {update.snapshot.first_row_id} < {base_metadata.next_row_id}")
441-
442-
443-
439+
elif (
440+
base_metadata.format_version >= 3
441+
and update.snapshot.first_row_id is not None
442+
and base_metadata.next_row_id is not None
443+
and update.snapshot.first_row_id < base_metadata.next_row_id
444+
):
445+
raise ValueError(
446+
f"Cannot add a snapshot with first row id smaller than the table's next-row-id {update.snapshot.first_row_id} < {base_metadata.next_row_id}"
447+
)
444448

445449
context.add_update(update)
446450
return base_metadata.model_copy(
447451
update={
448452
"last_updated_ms": update.snapshot.timestamp_ms,
449453
"last_sequence_number": update.snapshot.sequence_number,
450454
"snapshots": base_metadata.snapshots + [update.snapshot],
451-
"next-row-id": base_metadata.next_row_id + update.snapshot.added_rows
455+
"next_row_id": base_metadata.next_row_id + update.snapshot.added_rows
456+
if base_metadata.next_row_id is not None and update.snapshot.added_rows is not None
457+
else None,
452458
}
453459
)
454460

0 commit comments

Comments
 (0)