Skip to content

feat(encryption): [14/N] Add EncryptedOutputFile - #4380

Merged
kevinjqliu merged 3 commits into
apache:mainfrom
xanderbailey:xb/encryption-write-manifests
Nov 19, 2026
Merged

kevinjqliu merged 3 commits into
apache:mainfrom
xanderbailey:xb/encryption-write-manifests

Conversation

@xanderbailey

Copy link
Copy Markdown
Contributor

Working towards #3222

Rationale for this change

Adds EncryptedOutputFile, the write-side counterpart of EncryptedInputFile. It writes a file as an AGS1 stream and exposes its key metadata, including the written file length.

Manifests and manifest lists will be written through it once v3 manifest writing (#3624) lands.

Are these changes tested?

Yes, a file written this way reads back through EncryptedInputFile.

Are there any user-facing changes?

No.

Writes a file, such as a manifest, as an AGS1 stream and records its key
metadata with the written file length.
@xanderbailey
xanderbailey marked this pull request as ready for review November 14, 2026 20:18
@xanderbailey

Copy link
Copy Markdown
Contributor Author

@kevinjqliu this one is ready for a review I think when you have a moment

kevinjqliu and others added 2 commits November 19, 2026 10:21
Otherwise garbage collection calls close again and retries the write.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
"""The key metadata to record for the file, including the length of the written file."""
if self._file_length is None:
raise ValueError(f"Cannot get key metadata before the file is written: {self.location}")
return replace(self._key_metadata, file_length=self._file_length)

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.

note that we proactively update the _key_metadata's file_length after writing

Comment on lines +85 to +88
return _EncryptingOutputStream(self._output_file.create(overwrite=overwrite), self._key_metadata, self._set_file_length)

def _set_file_length(self, file_length: int) -> None:
self._file_length = file_length

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.

_file_length is a callback, passed to _EncryptingOutputStream

@kevinjqliu kevinjqliu 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.

LGTM

i added 2 nit fixes:

  • add try/finally to _EncryptingOutputStream cd1ce17
  • add @override to EncryptedOutputFile 1cc93a4

@kevinjqliu
kevinjqliu enabled auto-merge November 19, 2026 18:25
@kevinjqliu

Copy link
Copy Markdown
Contributor

thanks @xanderbailey

@xanderbailey

Copy link
Copy Markdown
Contributor Author

Awesome stuff, that means I think #3624 is the only blocker now!

@kevinjqliu
kevinjqliu added this pull request to the merge queue Nov 19, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to Branch Protection failures Nov 19, 2026
You're not authorized to push to this branch. Visit "About protected branches" for more information.
@kevinjqliu
kevinjqliu added this pull request to the merge queue Nov 19, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 19, 2026
@kevinjqliu
kevinjqliu added this pull request to the merge queue Nov 19, 2026
@kevinjqliu

Copy link
Copy Markdown
Contributor

merge queue is failing because the markdown-link-check check is flakey

@kevinjqliu

Copy link
Copy Markdown
Contributor

@xanderbailey i added #4431 to test E2E spark writing encrypted table and pyiceberg reading. Could you take a look when you get a chance?

Merged via the queue into apache:main with commit 046e584 Nov 19, 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