Skip to content

Commit 7bf4170

Browse files
committed
fix: issue with unset writer
1 parent f34d9f9 commit 7bf4170

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

pyiceberg/manifest.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -858,12 +858,12 @@ def __exit__(
858858
self._current_writer.__exit__(exc_type, exc_value, traceback)
859859

860860
def _get_current_writer(self) -> ManifestWriter:
861+
if self._should_roll_to_new_file():
862+
self._close_current_writer()
861863
if not self._current_writer:
862864
self._current_writer = next(self._supplier)
863865
self._current_writer.__enter__()
864866
return self._current_writer
865-
if self._should_roll_to_new_file():
866-
self._close_current_writer()
867867
return self._current_writer
868868

869869
def _should_roll_to_new_file(self) -> bool:
@@ -890,6 +890,7 @@ def add_entry(self, entry: ManifestEntry) -> RollingManifestWriter:
890890
if self._closed:
891891
raise RuntimeError("Cannot add entry to closed manifest writer")
892892
self._get_current_writer().add_entry(entry)
893+
self._current_file_rows += entry.data_file.record_count
893894
return self
894895

895896

0 commit comments

Comments
 (0)