Skip to content

Add s3.allow-delayed-open property for PyArrowFileIO - #4518

Merged
Fokko merged 1 commit into
apache:mainfrom
dor-bernstein:s3-allow-delayed-open
Nov 29, 2026
Merged

Fokko merged 1 commit into
apache:mainfrom
dor-bernstein:s3-allow-delayed-open

Conversation

@dor-bernstein

Copy link
Copy Markdown
Contributor

Rationale for this change

PyArrowFileIO builds pyarrow.fs.S3FileSystem without allow_delayed_open, which defaults to False. With that default, Arrow's S3 output stream calls CreateMultipartUpload as soon as a file is opened (s3fs.cc, ObjectOutputStream::Init). Every object pyiceberg writes, including a 2 KB manifest list, then costs three requests: CreateMultipartUpload, UploadPart and CompleteMultipartUpload.

With allow_delayed_open=True, Arrow defers the upload, and objects under the 10 MiB part size are sent as a single PutObject on close. Manifests, manifest lists and metadata.json are almost always under that size, so on a write-heavy table this cuts the S3 write requests of a commit by roughly two-thirds. We measured this in S3 server access logs: about 1.07 parts per multipart upload, so the Create/Complete pair is nearly all overhead.

This PR adds an s3.allow-delayed-open FileIO property that is passed through to S3FileSystem for s3:// and oss://. pyarrow exposes the option from 21.0.0, so the property uses the same version guard as s3.ssl.ca-cert. When it is unset, nothing changes.

The trade-off, from the pyarrow docs, is that errors that would surface on open, such as a missing bucket, are reported on write or close instead.

Are these changes tested?

Yes. There are unit tests in tests/io/test_pyarrow.py for:

  • true / false reaching S3FileSystem for s3://, and true for oss://
  • the kwarg being left out when the property is unset
  • an ImportError on pyarrow < 21

Are there any user-facing changes?

Yes: a new optional FileIO property, s3.allow-delayed-open, documented in configuration.md. The default behavior is unchanged.

🤖 Generated with Claude Code

pyarrow's S3 output stream starts a multipart upload when a file is
opened unless S3FileSystem(allow_delayed_open=True) is set, so every
object PyArrowFileIO writes (manifests, manifest lists, metadata.json)
costs CreateMultipartUpload + UploadPart + CompleteMultipartUpload.
With the flag on, objects under the 10 MiB part size go out as a single
PutObject. pyarrow exposes the option from 21.0.0, so the property is
guarded the same way as s3.ssl.ca-cert.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@Fokko Fokko left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice add, thanks @dor-bernstein

@Fokko
Fokko added this pull request to the merge queue Nov 29, 2026
Merged via the queue into apache:main with commit c73bee8 Nov 29, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants