Fokko commented on code in PR #4272:
URL: https://github.com/apache/iceberg-python/pull/4272#discussion_r4769330021
##########
pyiceberg/table/inspect.py:
##########
@@ -986,15 +988,13 @@ def _all_files(self, data_file_filter:
set[DataFileContent] | None = None) -> pa
"""
import pyarrow as pa
- snapshots = self.tbl.snapshots()
- if not snapshots:
- return pa.Table.from_pylist([], schema=self._get_files_schema())
-
executor = ExecutorFactory.get_or_create()
encryption_manager = self.tbl.encryption_manager
- manifest_lists = executor.map(lambda snapshot:
snapshot.manifests(self.tbl.io, encryption_manager), snapshots)
+ manifest_lists = executor.map(lambda snapshot:
snapshot.manifests(self.tbl.io, encryption_manager), self.tbl.snapshots())
unique_manifests = {(manifest.manifest_path, manifest) for
manifest_list in manifest_lists for manifest in manifest_list}
+ if not unique_manifests:
Review Comment:
Nit: Since we now return early when there are no manifests rather than no
snapshots, could we update the `Returns:` section of the docstring to match? It
still says "or an empty table if the table has no snapshots".
##########
tests/table/test_inspect.py:
##########
@@ -104,6 +104,23 @@ def
test_inspect_entries_and_files_with_data_file_without_metrics(catalog: InMem
assert files[0]["column_sizes"] is None
[email protected]("method", ["files", "data_files", "delete_files",
"all_files", "all_data_files", "all_delete_files"])
+def test_inspect_files_of_snapshot_without_manifests(catalog: InMemoryCatalog,
method: str) -> None:
+ tbl = catalog.create_table("default.no_manifests", Schema(NestedField(1,
"x", LongType(), required=False)))
+ tbl.append(pa.table({"x": pa.array([], pa.int64())}))
+
+ assert getattr(tbl.inspect, method)() ==
tbl.inspect._get_files_schema().empty_table()
Review Comment:
nit (non-blocking): These are six simple cases on the same table, so a loop
avoids creating the table six times:
```suggestion
def test_inspect_files_of_snapshot_without_manifests(catalog:
InMemoryCatalog) -> None:
tbl = catalog.create_table("default.no_manifests", Schema(NestedField(1,
"x", LongType(), required=False)))
tbl.append(pa.table({"x": pa.array([], pa.int64())}))
expected = tbl.inspect._get_files_schema().empty_table()
for method in ["files", "data_files", "delete_files", "all_files",
"all_data_files", "all_delete_files"]:
assert getattr(tbl.inspect, method)() == expected, method
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]