Skip to content

Commit 6da3977

Browse files
committed
linter
1 parent 9d5417f commit 6da3977

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

pyiceberg/table/snapshots.py

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

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

pyiceberg/table/update/__init__.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -418,21 +418,27 @@ def _(update: AddSnapshotUpdate, base_metadata: TableMetadata, context: _TableMe
418418
f"Cannot add snapshot with sequence number {update.snapshot.sequence_number} "
419419
f"older than last sequence number {base_metadata.last_sequence_number}"
420420
)
421-
elif (base_metadata.format_version >= 3 and update.snapshot.first_row_id is None):
421+
elif base_metadata.format_version >= 3 and update.snapshot.first_row_id is None:
422422
raise ValueError("Cannot add snapshot without first row id")
423-
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):
424-
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}")
425-
426-
427-
423+
elif (
424+
base_metadata.format_version >= 3
425+
and update.snapshot.first_row_id is not None
426+
and base_metadata.next_row_id is not None
427+
and update.snapshot.first_row_id < base_metadata.next_row_id
428+
):
429+
raise ValueError(
430+
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}"
431+
)
428432

429433
context.add_update(update)
430434
return base_metadata.model_copy(
431435
update={
432436
"last_updated_ms": update.snapshot.timestamp_ms,
433437
"last_sequence_number": update.snapshot.sequence_number,
434438
"snapshots": base_metadata.snapshots + [update.snapshot],
435-
"next-row-id": base_metadata.next_row_id + update.snapshot.added_rows
439+
"next_row_id": base_metadata.next_row_id + update.snapshot.added_rows
440+
if base_metadata.next_row_id is not None and update.snapshot.added_rows is not None
441+
else None,
436442
}
437443
)
438444

@@ -589,6 +595,7 @@ def _(update: RemoveStatisticsUpdate, base_metadata: TableMetadata, context: _Ta
589595

590596
return base_metadata.model_copy(update={"statistics": statistics})
591597

598+
592599
def update_table_metadata(
593600
base_metadata: TableMetadata,
594601
updates: Tuple[TableUpdate, ...],

0 commit comments

Comments
 (0)