-
Notifications
You must be signed in to change notification settings - Fork 4.2k
GH-41246: [Docs][C++][Python] Improve docs on column encryption for nested fields #45411
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
AlenkaF
merged 16 commits into
apache:main
from
EnricoMi:docs-column-encryption-nested-fields
Mar 26, 2025
Merged
Changes from 5 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
0de6062
Notes on column encryption with nested fields in Python docs
EnricoMi 56e803d
Notes on column encryption with nested fields in C++ docs
EnricoMi 034205b
Improving example code per review comments
EnricoMi 2b1355e
Align column_keys format in EncryptionConfiguration with docs
EnricoMi ee6e96d
Fix rst syntax
EnricoMi 30c6184
Move example C++ code into file
EnricoMi f4f8483
Improve docs
EnricoMi a7cdee8
Merge remote-tracking branch 'origin/main' into docs-column-encryptio…
EnricoMi d2ed421
Minor changes to docs and example
EnricoMi ff9e2e2
Don't include example file, link it
EnricoMi dbfcaed
Revert "Don't include example file, link it"
EnricoMi 52fb219
Move full example to Parquet column encryption example page
EnricoMi ad6d60e
Apply suggested rewording
EnricoMi f1ca4c2
Improve imports of example
EnricoMi fabde12
Add import to Python example
EnricoMi b47168d
Account for review comments
EnricoMi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -703,7 +703,7 @@ creating file encryption properties) includes the following options: | |
| * ``footer_key``, the ID of the master key for footer encryption/signing. | ||
| * ``column_keys``, which columns to encrypt with which key. Dictionary with | ||
| master key IDs as the keys, and column name lists as the values, | ||
| e.g. ``{key1: [col1, col2], key2: [col3]}`` . | ||
| e.g. ``{key1: [col1, col2], key2: [col3]}``. See notes on nested fields below. | ||
| * ``encryption_algorithm``, the Parquet encryption algorithm. | ||
| Can be ``AES_GCM_V1`` (default) or ``AES_GCM_CTR_V1``. | ||
| * ``plaintext_footer``, whether to write the file footer in plain text (otherwise it is encrypted). | ||
|
|
@@ -739,6 +739,37 @@ An example encryption configuration: | |
| }, | ||
| ) | ||
|
|
||
| .. note:: | ||
| Encrypting columns that have nested fields (for instance struct, map, or even list data types) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (same suggestions as for C++) |
||
| require configuring column keys for the inner fields, not the column itself. | ||
| Configuring a column key for the column itself causes this error (here column name is ``col``): | ||
|
|
||
| .. code-block:: | ||
|
|
||
| OSError: Encrypted column col not in file schema | ||
|
|
||
| An example encryption configuration for columns with nested fields, where | ||
| all of the columns will be encrypted with the key identified by ``column_key_id``: | ||
|
EnricoMi marked this conversation as resolved.
Outdated
|
||
|
|
||
| .. code-block:: python | ||
|
|
||
| schema = pa.schema([ | ||
| ("ListColumn", pa.list_(pa.int32())), | ||
| ("MapColumn", pa.map_(pa.string(), pa.int32())), | ||
| ("StructColumn", pa.struct([("f1", pa.int32()), ("f2", pa.string())])), | ||
| ]) | ||
|
|
||
| encryption_config = pq.EncryptionConfiguration( | ||
| footer_key="footer_key_name", | ||
| column_keys={ | ||
| "column_key_id": [ | ||
| "ListColumn.list.element", | ||
| "MapColumn.key_value.key", "MapColumn.key_value.value", | ||
| "StructColumn.f1", "StructColumn.f2" | ||
| ], | ||
| }, | ||
| ) | ||
|
|
||
| Decryption configuration | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jorisvandenbossche @AlenkaF @raulcd What is our preferred policy for code examples? Do we put them inline in the docs? Do we use separate files?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update: it seems we use
literalincludedirectives from C++ example files that are compiled as part of CI runs. See for example https://github.com/apache/arrow/blob/main/docs/source/cpp/dataset.rst#reading-datasets