Skip to content

Commit 351a1ca

Browse files
committed
PR comments
1 parent ac1636a commit 351a1ca

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

pyiceberg/table/snapshots.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,22 @@ def __str__(self) -> str:
257257
result_str = f"{operation}id={self.snapshot_id}{parent_id}{schema_id}"
258258
return result_str
259259

260+
def __repr__(self) -> str:
261+
"""Return the string representation of the Snapshot class."""
262+
fields = [
263+
f"snapshot_id={self.snapshot_id}",
264+
f"parent_snapshot_id={self.parent_snapshot_id}",
265+
f"sequence_number={self.sequence_number}",
266+
f"timestamp_ms={self.timestamp_ms}",
267+
f"manifest_list='{self.manifest_list}'",
268+
f"summary={repr(self.summary)}" if self.summary else None,
269+
f"schema_id={self.schema_id}" if self.schema_id is not None else None,
270+
f"first_row_id={self.first_row_id}" if self.first_row_id is not None else None,
271+
f"added_rows={self.added_rows}" if self.added_rows is not None else None,
272+
]
273+
filtered_fields = [field for field in fields if field is not None]
274+
return f"Snapshot({', '.join(filtered_fields)})"
275+
260276
def manifests(self, io: FileIO) -> List[ManifestFile]:
261277
"""Return the manifests for the given snapshot."""
262278
return list(_manifests(io, self.manifest_list))

tests/integration/test_writes/test_writes.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2493,13 +2493,12 @@ def test_stage_only_overwrite_files(
24932493

24942494

24952495
@pytest.mark.integration
2496-
def test_v3_write_and_read(spark: SparkSession, session_catalog: Catalog) -> None:
2496+
def test_v3_write_and_read_row_lineage(spark: SparkSession, session_catalog: Catalog) -> None:
24972497
"""Test writing to a v3 table and reading with Spark."""
24982498
identifier = "default.test_v3_write_and_read"
24992499
tbl = _create_table(session_catalog, identifier, {"format-version": "3"})
25002500
assert tbl.format_version == 3, f"Expected v3, got: v{tbl.format_version}"
2501-
assert tbl.metadata.next_row_id is not None, "Expected next_row_id to be initialized"
2502-
initial_next_row_id = tbl.metadata.next_row_id
2501+
initial_next_row_id = tbl.metadata.next_row_id or 0
25032502

25042503
test_data = pa.Table.from_pydict(
25052504
{
@@ -2527,7 +2526,4 @@ def test_v3_write_and_read(spark: SparkSession, session_catalog: Catalog) -> Non
25272526

25282527
assert (
25292528
tbl.metadata.next_row_id == initial_next_row_id + len(test_data)
2530-
), "Expected next_row_id to be incremented by the number of added rows"
2531-
2532-
df = spark.table(identifier)
2533-
assert df.count() == 3, "Expected 3 rows"
2529+
), "Expected next_row_id to be incremented by the number of added rows"

0 commit comments

Comments
 (0)