shashank11yadav opened a new pull request, #4620: URL: https://github.com/apache/iceberg-python/pull/4620
Fixes #4619 # Rationale for this change `InspectTable._files` checked `if not snapshot_id and ...`, so an explicit `snapshot_id=0` was treated the same as "no snapshot id". On a table with no snapshots, `files()`, `data_files()` and `delete_files()` then returned an empty table for `snapshot_id=0`, instead of raising `ValueError: Cannot find snapshot with ID 0` as every other unknown id does. The fix checks `snapshot_id is None`, as `_get_snapshot` already does. Calls without a `snapshot_id` still return an empty table on a table without snapshots, as the method docstring describes. ## Are these changes tested? Yes. One new test, `test_inspect_files_with_snapshot_id_zero_on_table_without_snapshots`, in `tests/table/test_inspect.py`. For all three methods it checks that the default call returns no rows and that `snapshot_id=0` raises `ValueError`. The new test fails without the fix. With the fix applied, the new test passes. Local results on this commit: - The `tests/table/test_inspect.py` file, with the unit marker: pass. - The new test on its own: pass. - ruff check: pass. - ruff format check on the two changed files: pass. - mypy on `pyiceberg` and `tests`: pass. `make lint` (the full pre-commit hook set) was not run, so the lint result above covers only ruff. ## Are there any user-facing changes? Yes, a behaviour change. An explicit `snapshot_id=0` on a table with no snapshots now raises `ValueError` in `inspect.files()`, `data_files()` and `delete_files()`. Before, it returned an empty table. Calls without a `snapshot_id` are unchanged, and no other call path changes. Please add the `changelog` label, since this changes behaviour. -- 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]
