Skip to content

Commit 74e42e0

Browse files
committed
more fixes
1 parent 6913f09 commit 74e42e0

3 files changed

Lines changed: 7 additions & 27 deletions

File tree

pyiceberg/table/__init__.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@ def update_snapshot(self, snapshot_properties: Dict[str, str] = EMPTY_DICT) -> U
438438
def rewrite_manifests(self) -> RewriteManifestsResult:
439439
if self._table.current_snapshot() is None:
440440
return RewriteManifestsResult(rewritten_manifests=[], added_manifests=[])
441+
441442
with self.update_snapshot().rewrite() as rewrite:
442443
rewritten = rewrite.rewrite_manifests()
443444
return rewritten
@@ -1375,20 +1376,6 @@ def add_files(
13751376
file_paths=file_paths, snapshot_properties=snapshot_properties, check_duplicate_files=check_duplicate_files
13761377
)
13771378

1378-
def rewrite_manifests(
1379-
self,
1380-
spec_id: Optional[int] = None,
1381-
) -> RewriteManifestsResult:
1382-
"""
1383-
Shorthand API for Rewriting manifests for the table.
1384-
1385-
Args:
1386-
spec_id: Spec id of the manifests to rewrite (defaults to current spec id)
1387-
1388-
"""
1389-
with self.transaction() as tx:
1390-
return tx.rewrite_manifests(spec_id=spec_id)
1391-
13921379
def update_spec(self, case_sensitive: bool = True) -> UpdateSpec:
13931380
return UpdateSpec(Transaction(self, autocommit=True), case_sensitive=case_sensitive)
13941381

pyiceberg/table/update/snapshot.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -474,19 +474,11 @@ def _deleted_entries(self) -> List[ManifestEntry]:
474474
return []
475475

476476

477-
@dataclass(init=False)
477+
@dataclass(frozen=True)
478478
class RewriteManifestsResult:
479479
rewritten_manifests: List[ManifestFile] = field(default_factory=list)
480480
added_manifests: List[ManifestFile] = field(default_factory=list)
481481

482-
def __init__(
483-
self,
484-
rewritten_manifests: Optional[List[ManifestFile]],
485-
added_manifests: Optional[List[ManifestFile]],
486-
) -> None:
487-
self.rewritten_manifests = rewritten_manifests or []
488-
self.added_manifests = added_manifests or []
489-
490482

491483
class _MergeAppendFiles(_FastAppendFiles):
492484
_target_size_bytes: int
@@ -653,14 +645,15 @@ def _find_matching_manifests(self, snapshot: Snapshot, content: ManifestContent)
653645
return RewriteManifestsResult(rewritten_manifests=manifests, added_manifests=new_manifests)
654646

655647
def _copy_manifest_file(self, manifest_file: ManifestFile, snapshot_id: int) -> ManifestFile:
656-
return ManifestFile(
648+
return ManifestFile.from_args(
649+
_table_format_version=self._transaction.table_metadata.format_version,
657650
manifest_path=manifest_file.manifest_path,
658651
manifest_length=manifest_file.manifest_length,
659652
partition_spec_id=manifest_file.partition_spec_id,
660653
content=manifest_file.content,
661654
sequence_number=manifest_file.sequence_number,
662655
min_sequence_number=manifest_file.min_sequence_number,
663-
added_snapshot_id=snapshot_id,
656+
added_snapshot_id=snapshot_id, # Using the new snapshot ID here
664657
added_files_count=manifest_file.added_files_count,
665658
existing_files_count=manifest_file.existing_files_count,
666659
deleted_files_count=manifest_file.deleted_files_count,

tests/integration/test_inspect_table.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,6 +1102,7 @@ def test_inspect_files_partitioned(spark: SparkSession, session_catalog: Catalog
11021102
)
11031103
assert_frame_equal(lhs, rhs, check_dtype=False)
11041104

1105+
11051106
def test_inspect_all_example(spark: SparkSession, session_catalog: Catalog, format_version: int) -> None:
11061107
from pandas.testing import assert_frame_equal
11071108

@@ -1140,6 +1141,5 @@ def test_inspect_all_example(spark: SparkSession, session_catalog: Catalog, form
11401141

11411142
tbl.refresh()
11421143

1143-
11441144
tbl.rewrite_manifests()
1145-
print("efd")
1145+
print("efd")

0 commit comments

Comments
 (0)