feat(python): Python binding for iceberg-rust FileIO#2
Draft
abnobdoss wants to merge 7 commits into
Draft
Conversation
added 7 commits
May 24, 2026 16:24
…ore_rust Add `bytes = "1"` to the Python binding's Cargo.toml (needed for explicit byte-slice conversion in file_io.rs) and register file_io::register_module in lib.rs, placing it alongside the existing transform/manifest registrations.
…-rust FileIO Exposes iceberg-rust's `FileIO` to Python via three pyclasses: - `FileIO.from_props(dict)` — primary constructor matching the same OpenDalResolvingStorageFactory plumbing already used by IcebergDataFusionTable, now returning a reusable handle instead of discarding after construction. Callers amortize setup across thousands of file opens in a single query. - `FileIO.exists(path)` / `FileIO.delete(path)` — async ops via the shared Tokio runtime handle. - `FileIO.new_input(path)` / `FileIO.new_output(path)` — sync (InputFile/OutputFile hold the storage Arc internally). - `InputFile.read()` → `bytes`, `InputFile.exists()`, `InputFile.metadata()` → dict. - `OutputFile.write(bytes)` — one-shot write. - `__repr__` on FileIO redacts any key containing secret/key/token/password/credential/passphrase.
Bare signatures for FileIO, InputFile, and OutputFile with a module-level docstring explaining from_props(dict) as the primary constructor and the credential-redaction behaviour of __repr__.
30 tests covering: - from_props construction (empty dict, partial props, handle independence) - __repr__ credential redaction for 7 sensitive key patterns - exists/delete via FileIO - OutputFile.write (create, overwrite, empty bytes) - InputFile.exists, read, metadata - round-trip write→read - repr format for InputFile and OutputFile All tests use tmp_path for filesystem isolation; no network deps.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Status
Blocked for now while the Predicate binding stack settles. This draft is runtime-only; Python typing stubs are deferred to a separate package-wide follow-up PR.
What is this
Exposes
iceberg::io::FileIOto Python as three pyclasses inpyiceberg_core.file_io:FileIO— reusable handle constructed viaFileIO.from_props(props: dict[str, str]); backed byOpenDalResolvingStorageFactoryso it resolves supported storage schemes from the pathInputFile— returned byFileIO.new_input(path), exposeslocation(),exists(),read() -> bytes, andsize() -> intOutputFile— returned byFileIO.new_output(path), exposeslocation()andwrite(bytes)FileIOalso exposes path-basedexists(path)anddelete(path).Motivation
This gives Python callers direct access to iceberg-rust's existing
FileIOabstraction, including reuse of the same handle across many file opens. That is the binding shape used by the Rust API and avoids forcing callers into one-off dict-based helper functions for every path.The blocking I/O calls release the Python GIL via PyO3's
Python::detach, so Python threads are not serialized while the Rust runtime waits on storage operations.This PR is one small building block for Rust-backed PyIceberg reads; it does not claim to complete the broader Python integration surface.
Files changed
bindings/python/src/file_io.rsbindings/python/src/lib.rsfile_iomodulebindings/python/tests/test_file_io.pybindings/python/Cargo.lockcargo update --workspace --lockedpasses with the existingopendal-alldependency setNo new direct Cargo dependency is added.
Test coverage
21 pytest cases pass against the built wheel. All tests use local
file://URIs viatmp_path; no network or cloud credentials are required.Covered behavior includes construction, reusable handles across many opens, credential redaction in
FileIO.__repr__, path-basedexists/delete, write create / overwrite / boundary payload sizes, read, size, missing-input errors, and handle locations / reprs.What this PR is NOT
FileScanTaskorArrowReaderPyArrowFileIOorfsspecin PyIceberg.pyifiles andpy.typedare deferred to a package-wide follow-up