GH-40502: [Python] Expose NativeFile.abort() - #1
Closed
adrien-grl wants to merge 2 commits into
Closed
adrien-grl wants to merge 2 commits into
adrien-grl wants to merge 2 commits into
Conversation
adrien-grl
force-pushed
the
GH-40502-nativefile-abort
branch
from
September 29, 2026 09:59
2a81e57 to
6c0fccb
Compare
Owner
Author
|
Opened upstream as apache#51631. |
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.
Rationale for this change
Closing an output stream always commits what was written, so a job that fails halfway through still leaves a partial object on S3. Arrow C++ already has
Abort()for this, and the S3 stream implements it by aborting the multipart upload, but it wasn't reachable from Python.What changes are included in this PR?
This adds
NativeFile.abort(), which callsFileInterface::Abort()the same wayclose()callsClose(). The example from the issue now works:Are these changes tested?
Yes.
test_open_output_stream_abortruns on all the filesystem fixtures, with and without compression and buffering. It checks that nothing is written on S3, and that the mock filesystem sees an abort rather than a close.test_s3_output_stream_abort_after_part_uploadaborts after a 10 MiB part has already been uploaded, which I don't think the C++ tests cover. There are also two small tests intest_io.pyfor aborting in-memory streams.Backends other than S3 don't discard anything on abort today so the tests are pretty light for the other backends. I ran it against minio, azurite and the GCS testbench. Local, GCS and fsspec keep the written data, since their
Abort()just closes. Azure leaves an empty blob, because the blob is created when the stream is opened. Those seem worth separate issues.test_io.pyandtest_fs.pypass locally with S3, Azure and GCS enabled.Are there any user-facing changes?
Yes,
NativeFile.abort()is new.Was AI used for this PR?
In accordance to the AI generation guidelines, please disclose below whether and how AI was used in this PR.
I used Claude Code to write the code, the tests and this description, and to run the tests locally.
PR code and description written by:
Reviewed before submission by: