Skip to content

feat(encryption) [15/N] write encrypted parquet data files#2701

Open
aarushigupta132 wants to merge 7 commits into
apache:mainfrom
aarushigupta132:feat/encrypted-parquet-data-files
Open

feat(encryption) [15/N] write encrypted parquet data files#2701
aarushigupta132 wants to merge 7 commits into
apache:mainfrom
aarushigupta132:feat/encrypted-parquet-data-files

Conversation

@aarushigupta132

@aarushigupta132 aarushigupta132 commented Jun 23, 2026

Copy link
Copy Markdown

Which issue does this PR close?

Working towards #2034.

What changes are included in this PR?

Adds support for writing Iceberg data files with Parquet Modular Encryption.

When a table is configured for encryption, ParquetWriterBuilder::from_table_properties derives the data-encryption key size from the table properties. ParquetWriter then mints a fresh per-file DEK, writes the file encrypted, and records the encoded key metadata on the resulting DataFile so readers can decrypt.

Are these changes tested?

Existing ParquetWriter tests pass; encryption round-trip coverage lands later in the series.

@aarushigupta132 aarushigupta132 changed the title Feat/encrypted parquet data files feat(encryption): write encrypted parquet data files Jun 23, 2026
@aarushigupta132
aarushigupta132 marked this pull request as ready for review June 23, 2026 23:45

@xanderbailey xanderbailey 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 carrying the flame on the encryption work. Have made a couple of comments to get us started.

Comment thread crates/iceberg/src/writer/file_writer/parquet_writer.rs Outdated
Comment thread crates/iceberg/src/writer/file_writer/parquet_writer.rs Outdated
@aarushigupta132 aarushigupta132 changed the title feat(encryption): write encrypted parquet data files feat(encryption) [15/N] write encrypted parquet data files Jul 15, 2026
@aarushigupta132
aarushigupta132 force-pushed the feat/encrypted-parquet-data-files branch 2 times, most recently from 58df8f8 to 0783948 Compare July 15, 2026 16:55
@aarushigupta132
aarushigupta132 force-pushed the feat/encrypted-parquet-data-files branch from 0783948 to b80ebbf Compare July 15, 2026 17:38
@aarushigupta132
aarushigupta132 force-pushed the feat/encrypted-parquet-data-files branch from 9c618e6 to 6ca9626 Compare July 15, 2026 23:03
@aarushigupta132
aarushigupta132 force-pushed the feat/encrypted-parquet-data-files branch from 6ca9626 to 12fa115 Compare July 15, 2026 23:17
@aarushigupta132
aarushigupta132 force-pushed the feat/encrypted-parquet-data-files branch from cc5fca7 to 74c54db Compare July 15, 2026 23:46
type R = ParquetWriter;

async fn build(&self, output_file: OutputFile) -> Result<Self::R> {
let key_metadata = self

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Confirmed that in rolling_writer as well, we build this again with new dek for each new parquet file

Comment on lines 65 to 67
/// When writing into an existing Iceberg table, prefer
/// [`Self::from_table_properties`], which derives `WriterProperties` from
/// the table's `write.parquet.*` properties.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

curious to know if we should deprecate new and new_with_match_mode in favor of from_table_properties. Or update the comment to prefer the latter in all cases?

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.

I would add a comment in the doc here that encrypted writing is not supported with this constructor. I would honestly be in favour of removing this constructor since it's not used in this crate and nor should it be. I don't think we should do that in this PR but it would be a good follow-up IMO.

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

Few more comments and a test for the writer would be great. Maybe also something that shows datafusion writer works but that can be a follow up

/// sized to `key_size`.
pub(crate) fn generate_standard_key_metadata(key_size: AesKeySize) -> StandardKeyMetadata {
let dek = SecureKey::generate(key_size);
StandardKeyMetadata::new(dek.as_bytes()).with_aad_prefix(&generate_aad_prefix())

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.

FYI: This will break after #2834 merges.

Comment on lines 65 to 67
/// When writing into an existing Iceberg table, prefer
/// [`Self::from_table_properties`], which derives `WriterProperties` from
/// the table's `write.parquet.*` properties.

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.

I would add a comment in the doc here that encrypted writing is not supported with this constructor. I would honestly be in favour of removing this constructor since it's not used in this crate and nor should it be. I don't think we should do that in this PR but it would be a good follow-up IMO.

}

fn resolve_writer_properties(
writer_properties: &WriterProperties,

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.

I would error if these WriterProperties already have encryption properties set.

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