Skip to content

Commit 130a96a

Browse files
committed
linter
1 parent 0dc458c commit 130a96a

2 files changed

Lines changed: 19 additions & 9 deletions

File tree

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
@@ -437,21 +437,27 @@ def _(update: AddSnapshotUpdate, base_metadata: TableMetadata, context: _TableMe
437437
f"Cannot add snapshot with sequence number {update.snapshot.sequence_number} "
438438
f"older than last sequence number {base_metadata.last_sequence_number}"
439439
)
440-
elif (base_metadata.format_version >= 3 and update.snapshot.first_row_id is None):
440+
elif base_metadata.format_version >= 3 and update.snapshot.first_row_id is None:
441441
raise ValueError("Cannot add snapshot without first row id")
442-
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):
443-
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}")
444-
445-
446-
442+
elif (
443+
base_metadata.format_version >= 3
444+
and update.snapshot.first_row_id is not None
445+
and base_metadata.next_row_id is not None
446+
and update.snapshot.first_row_id < base_metadata.next_row_id
447+
):
448+
raise ValueError(
449+
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}"
450+
)
447451

448452
context.add_update(update)
449453
return base_metadata.model_copy(
450454
update={
451455
"last_updated_ms": update.snapshot.timestamp_ms,
452456
"last_sequence_number": update.snapshot.sequence_number,
453457
"snapshots": base_metadata.snapshots + [update.snapshot],
454-
"next-row-id": base_metadata.next_row_id + update.snapshot.added_rows
458+
"next_row_id": base_metadata.next_row_id + update.snapshot.added_rows
459+
if base_metadata.next_row_id is not None and update.snapshot.added_rows is not None
460+
else None,
455461
}
456462
)
457463

0 commit comments

Comments
 (0)