Skip to content

chore(refactor) refactor ManifestWriterBuilder to take Box<dyn FileWrite> and location - #2568

Merged
blackmwk merged 3 commits into
apache:mainfrom
xanderbailey:xb/refactor-manifest-writer
Jun 4, 2026
Merged

blackmwk merged 3 commits into
apache:mainfrom
xanderbailey:xb/refactor-manifest-writer

Conversation

@xanderbailey

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Working towards: #2034

What changes are included in this PR?

Similar reasons to #2564. For the current encryption work we will construct a FileWrite to do transparent encryption on write, this means we need to change the constructor of the ManifestWriterBuilder to now take both a Box<dyn FileWrite> and a location.

Are these changes tested?

@xanderbailey
xanderbailey force-pushed the xb/refactor-manifest-writer branch from b83e6bb to d69e4c5 Compare June 2, 2026 08:39
/// Create a new builder.
pub fn new(
output: OutputFile,
writer: Box<dyn FileWrite>,

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.

We don't need to this breaking api change, instead, we could add a new method to accept encrypted output file, and these two methods share same function which accepts FileWriter.

@xanderbailey xanderbailey Jun 2, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not sure I quite follow sorry, is that to say we keep this constructor and store something like:

writer: Pin<Box<dyn Future<Output = Result<Box<dyn FileWrite>>> + Send>>

in the struct and have a new constructor:

    pub fn new_from_encrypted(
        encrypted_output: EncryptedOutputFile,
        snapshot_id: Option<i64>,
        key_metadata: Option<Vec<u8>>,
        schema: SchemaRef,
        partition_spec: PartitionSpec,
    ) -> Self {
        let location = encrypted_output.location().to_owned();
        Self {
            writer_future: Box::pin(async move { encrypted_output.writer().await }),
            location,
            snapshot_id,
            key_metadata,
            schema,
            partition_spec,
        }
    }

?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I tried it with the pinned future and added a new constructor, let me know what you think

@xanderbailey
xanderbailey force-pushed the xb/refactor-manifest-writer branch from f766298 to 774eda6 Compare June 3, 2026 11:39
Comment on lines 223 to +225
pub(crate) fn new(
output: OutputFile,
writer_future: WriterFuture,
location: String,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is pub(crate) so I think it's okay to change?

/// with the actual snapshot ID before it is committed.
const UNASSIGNED_SNAPSHOT_ID: i64 = -1;

type WriterFuture = Pin<Box<dyn Future<Output = Result<Box<dyn FileWrite>>> + Send>>;

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.

In fact I prefer to change to new method to async, but I think it's fine for now, let's see in future if we could eliminate it.

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

Thanks @xanderbailey for this pr!

@blackmwk
blackmwk merged commit f064f2b into apache:main Jun 4, 2026
21 checks passed
blackmwk pushed a commit that referenced this pull request Jul 1, 2026
…ile` in `ManifestWriterBuilder` (#2628)

## Which issue does this PR close?

<!--
We generally require a GitHub issue to be filed for all bug fixes and
enhancements and this helps us generate change logs for our releases.
You can link an issue to this PR using the GitHub syntax. For example
`Closes #123` indicates that this PR will close issue #123.
-->
In #2568 we introduced
`new_from_encrypted` but the api isn't very ergonomic because
`EncryptedOutputFile` has `StandardKeyMetadata` on it already so we
don't need to pass in `key_metadata` also.

working towards #2034 

## What changes are included in this PR?

<!--
Provide a summary of the modifications in this PR. List the main changes
such as new features, bug fixes, refactoring, or any other updates.
-->

## Are these changes tested?

<!--
Specify what test covers (unit test, integration test, etc.).

If tests are not included in your PR, please explain why (for example,
are they covered by existing tests)?
-->
blackmwk pushed a commit that referenced this pull request Jul 24, 2026
## Which issue does this PR close?
* Working towards #2034

## What changes are included in this PR?

Today it is possible to read encrypted manifest files but not write
them.

#2568 adds the foundations
of what's needed to be able to do these writes but it wasn't wired into
the actual write path.

<!--
Provide a summary of the modifications in this PR. List the main changes
such as new features, bug fixes, refactoring, or any other updates.
-->

## Are these changes tested?

Yes - added round-trip write path test.
<!--
Specify what test covers (unit test, integration test, etc.).

If tests are not included in your PR, please explain why (for example,
are they covered by existing tests)?
-->
blackmwk pushed a commit that referenced this pull request Jul 30, 2026
## Which issue does this PR close?

<!--
We generally require a GitHub issue to be filed for all bug fixes and
enhancements and this helps us generate change logs for our releases.
You can link an issue to this PR using the GitHub syntax. For example
`Closes #123` indicates that this PR will close issue #123.
-->

- Working towards #2034

## What changes are included in this PR?

Puffin files aren't yet used in the repo but we should support
encryption nevertheless, similar to
#2568, we add a
`new_from_encrypted` constructor for the reader and writer.
<!--
Provide a summary of the modifications in this PR. List the main changes
such as new features, bug fixes, refactoring, or any other updates.
-->

## Are these changes tested?
Yes - roundtrip test 
<!--
Specify what test covers (unit test, integration test, etc.).

If tests are not included in your PR, please explain why (for example,
are they covered by existing tests)?
-->
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