Skip to content

GH-31869: [Python][Parquet] Implement external key material features in Python - #48009

Merged
adamreeve merged 9 commits into
apache:mainfrom
pfparsons:feature/31869
Nov 12, 2025
Merged

adamreeve merged 9 commits into
apache:mainfrom
pfparsons:feature/31869

Conversation

@pfparsons

@pfparsons pfparsons commented Oct 30, 2025 •

Copy link
Copy Markdown
Contributor

Rationale for this change

Enables external key material and rotation for individual parquet files in PyArrow. This change does not address any parquet dataset encryption functionality.

What changes are included in this PR?

This PR enables external key material for parquet encryption from PyArrow:
Optional parquet_file_path and FileSystem paramters to CryptoFactory - mirroring the interface for CryptoFactory in C++

  1. Exposes the rotate_master_keys method of CryptoFactory

  2. Adds Cython classes for FileKeyMaterialStore, FileSystemKeyMaterialStore, and KeyMaterial - but does not expose these from PyArrow encryption. I included these changes only so that a unit test may verify an external store without leaking the implementation details for the store into the test.

Are these changes tested?

Yes - I've modified an existing test (previously marked pytest.xfail) to do a basic read write test and verify creation of the external key material store and added a test for CryptoFactory.rotate_master_keys.

Are there any user-facing changes?

  1. Users may optionally supply a parquet file path and FileSystem to CryptoFactory methods that provide en/decryption_properties. Doing so in conjunction with setting EncryptionConfiguration.internal_key_material=False enables external key material from pyarrow.
  2. PyArrow CryptoFactory now has a rotate_master_keys method exposing key rotation functionality from C++ CryptoFactory.

@github-actions

Copy link
Copy Markdown

Thanks for opening a pull request!

If this is not a minor PR. Could you open an issue for this pull request on GitHub? https://github.com/apache/arrow/issues/new/choose

Opening GitHub issues ahead of time contributes to the Openness of the Apache Arrow project.

Then could you also rename the pull request title in the following format?

GH-${GITHUB_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}

or

MINOR: [${COMPONENT}] ${SUMMARY}

See also:

@pfparsons pfparsons changed the title First pass at implementing external key material features in python GH-31869: [Python][Parquet] First pass at implementing external key material features in python Oct 30, 2025
@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #31869 has been automatically assigned in GitHub to PR creator.

1 similar comment
@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #31869 has been automatically assigned in GitHub to PR creator.

@github-actions

github-actions Bot commented Nov 4, 2025

Copy link
Copy Markdown

⚠️ GitHub issue #31869 has been automatically assigned in GitHub to PR creator.

@pfparsons

Copy link
Copy Markdown
Contributor Author

Hi @raulcd would you mind taking a look at this?

@raulcd raulcd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the PR @pfparsons !

I am not too familiar with the Parquet encryption side of things but I'll try to take a look. I am running CI at the moment. Maybe @EnricoMi @rok @adamreeve who have worked on Parquet Encryption in the past can take a look

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

Hi @pfparsons, thanks for the contribution! There are some minor formatting issues that the pre-commit script is reporting in https://github.com/apache/arrow/actions/runs/19077444221/job/54553464743?pr=48009, but the other CI failures are unrelated and are failing on main at the moment.

You can install pre-commit and run it locally to reproduce these errors, see https://pre-commit.com/. You can use something like pre-commit run --from-ref main --to-ref feature/31869 to run it on changes already committed.

I've left some comments with suggested changes, but this mostly looks really good to me. I'm not super familiar with cython though.

Comment thread python/pyarrow/_parquet_encryption.pyx Resolved
Comment thread python/pyarrow/_parquet_encryption.pyx Resolved
Comment thread python/pyarrow/_parquet_encryption.pyx Resolved
Comment thread python/pyarrow/_parquet_encryption.pyx Resolved
Comment thread python/pyarrow/_parquet_encryption.pyx Resolved
Comment thread python/pyarrow/_parquet_encryption.pyx Resolved
Comment thread python/pyarrow/_parquet_encryption.pyx Resolved
Comment thread python/pyarrow/_parquet_encryption.pyx Resolved

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

This looks good to me thanks @pfparsons. I've just left a couple of minor comments.

@EnricoMi EnricoMi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM, just a minor comment on the default value of a string parameter.

Comment thread python/pyarrow/_parquet_encryption.pyx Resolved
Changed defaults for get_{en,de}cryption_properties() parquet_file_path
args from empty string to None

Removed unsed custom_kms_conf arg from
test_external_key_material_rotation
@github-actions

github-actions Bot commented Nov 8, 2025

Copy link
Copy Markdown

⚠️ GitHub issue #31869 has been automatically assigned in GitHub to PR creator.

@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #31869 has been automatically assigned in GitHub to PR creator.

@adamreeve adamreeve changed the title GH-31869: [Python][Parquet] First pass at implementing external key material features in python GH-31869: [Python][Parquet] Implement external key material features in Python Nov 11, 2025
@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #31869 has been automatically assigned in GitHub to PR creator.

@conbench-apache-arrow

Copy link
Copy Markdown

After merging your PR, Conbench analyzed the 4 benchmarking runs that have been run so far on merge-commit 5112de2.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details. It also includes information about 137 possible false positives for unstable benchmarks that are known to sometimes produce them.

Mottl pushed a commit to Mottl/arrow that referenced this pull request May 26, 2026
…tures in Python (apache#48009)

### Rationale for this change
Enables external key material and rotation for individual parquet files in PyArrow.  This change does not address any parquet dataset encryption functionality.  

### What changes are included in this PR?
This PR enables external key material for parquet encryption from PyArrow:
Optional parquet_file_path and FileSystem paramters to CryptoFactory - mirroring the interface for CryptoFactory in C++

1. Exposes the rotate_master_keys method of CryptoFactory

2. Adds Cython classes for FileKeyMaterialStore, FileSystemKeyMaterialStore, and KeyMaterial - but does not expose these from PyArrow encryption.  I included these changes only so that a unit test may verify an external store without leaking the implementation details for the store into the test.

### Are these changes tested?
Yes - I've modified an existing test (previously marked pytest.xfail) to do a basic read write test and verify creation of the external key material store and added a test for CryptoFactory.rotate_master_keys.

### Are there any user-facing changes?

1. Users may optionally supply a parquet file path and FileSystem to CryptoFactory methods that provide en/decryption_properties.  Doing so in conjunction with setting EncryptionConfiguration.internal_key_material=False enables external key material from pyarrow.
2. PyArrow CryptoFactory now has a rotate_master_keys method exposing key rotation functionality from C++ CryptoFactory.

* GitHub Issue: apache#31869

Lead-authored-by: Patrick Parsons <[email protected]>
Co-authored-by: Adam Reeve <[email protected]>
Signed-off-by: Adam Reeve <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants