Skip to content

Commit a62c8cf

Browse files
committed
make older_than required
1 parent 3b3b10e commit a62c8cf

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

pyiceberg/table/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1376,7 +1376,7 @@ def to_polars(self) -> pl.LazyFrame:
13761376

13771377
return pl.scan_iceberg(self)
13781378

1379-
def delete_orphaned_files(self, older_than: Optional[timedelta] = timedelta(days=3), dry_run: bool = False) -> None:
1379+
def delete_orphaned_files(self, older_than: timedelta = timedelta(days=3), dry_run: bool = False) -> None:
13801380
"""Delete orphaned files in the table."""
13811381
location = self.location()
13821382
orphaned_files = self.inspect.orphaned_files(location, older_than)

pyiceberg/table/inspect.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ def all_known_files(self) -> dict[str, set[str]]:
688688

689689
return _all_known_files
690690

691-
def orphaned_files(self, location: str, older_than: Optional[timedelta] = timedelta(days=3)) -> Set[str]:
691+
def orphaned_files(self, location: str, older_than: timedelta = timedelta(days=3)) -> Set[str]:
692692
"""Get all the orphaned files in the table.
693693
694694
Args:
@@ -716,7 +716,7 @@ def orphaned_files(self, location: str, older_than: Optional[timedelta] = timede
716716
_, _, path = _parse_location(location)
717717
selector = FileSelector(path, recursive=True)
718718
# filter to just files as it may return directories, and filter on time
719-
as_of = datetime.now(timezone.utc) - older_than if older_than else None
719+
as_of = datetime.now(timezone.utc) - older_than
720720
all_files = [
721721
f.path for f in fs.get_file_info(selector) if f.type == FileType.File and (as_of is None or (f.mtime < as_of))
722722
]

0 commit comments

Comments
 (0)