Skip to content

API, Core: Introduce a generic EncryptedFile abstraction to replace ManifestListFile - #17545

Open
gaborkaszab wants to merge 1 commit into
apache:mainfrom
gaborkaszab:main_encryptable_file
Open

API, Core: Introduce a generic EncryptedFile abstraction to replace ManifestListFile#17545
gaborkaszab wants to merge 1 commit into
apache:mainfrom
gaborkaszab:main_encryptable_file

Conversation

@gaborkaszab

Copy link
Copy Markdown
Contributor

ManifestListFile and its implementation contains nothing that is specific to manifest lists. It is more generally related to files that use TableMetadata.encryptionKeys to store encrypted encryption key metadata that are referred to by a key ID.

This PR introduces a more general interface that can be used accross multiple file types like manifest lists, V4 root manifests, table statistics and partition statistics. The less general functionality specific to manifest lists is deprecated or removed where possible.

* @deprecated will be removed in 2.0.0; use {@link #newInputFile(EncryptableFile)} instead.
*/
@Deprecated
default InputFile newInputFile(ManifestListFile manifestList) {

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 dropped BaseManifestListFile because that was package private. Now, there is no implementation in the library that can call this function, still I don't think we can drop this, because it'd break API for users that happen to implement their own ManifestListFile. Not likely, but technically feasible.

* A file that may be encrypted. If it is encrypted, its encrypted key metadata is tracked in the
* table metadata encryption keys and is referenced by a key ID.
*/
public interface EncryptableFile {

@stevenzwu stevenzwu Aug 7, 2026

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.

Naming: "Encryptable" describes a capability every file has, not the specific concept/state represented here. I would suggest EncryptedFile and let the Javadoc cover the "may or may not carry a keyId" case.

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.

Changed to EncryptedFile, however, I'm still not comfortable with the vile name. The name suggests the file is encrypted, but it's may or may not. Maybe FileWithEncryptedKey ?

* The file key metadata can be encrypted. Returns ID of encryption key or null if it's not
* encrypted.
*/
String encryptionKeyID();

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.

  • encryptionKeyID()keyId() for consistency with Snapshot.keyId() and EncryptedKey.keyId() (ID caps is out of style — even the local variables in EncryptionUtil are manifestListKeyId).
  • Javadoc suggestion: /** Returns the encryption key ID for this file, or null if the file is not encrypted. */ — the interface-level javadoc already covers the mapping to TableMetadata.encryptionKeys(), so the method sentence can stay short.

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.

Thanks for the comment suggestion! Applied.

About the function name: I'm not sure we can change the function name, because that would break the API for ManifestListFile that is derived from this interface.
Alternatively, we can avoid deriving ManifestListFile from the new interface, but then we won't be able to cast it to the new interface and delegate to the new function signature like in FileIO or in EncryptionUtil:
newInputFile((EncryptableFile) manifestList)

/**
* A manifest list file that may be encrypted.
*
* @deprecated will be removed in 2.0.0; use {@link EncryptableFile} instead.

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.

nit: do we need to provide since? @deprecated since 1.12.0. Will be removed in 2.0.0?

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 added for now, but I personally don't feel it's useful to the reader.

"Snapshot key metadata encryption requires a StandardEncryptionManager");
StandardEncryptionManager sem = (StandardEncryptionManager) em;
String manifestListKeyId = manifestList.encryptionKeyID();
String fileKeyId = file.encryptionKeyID();

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.

nit: encryptionKeyId might be more clear. similarly, maybe also fileKey -> encryptionKey below.

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.

Renamed them

@stevenzwu stevenzwu changed the title API, Core: Refactor: Introduce a more general abstraction to replace ManifestListFile API, Core: Introduce a generic EncryptedFile abstraction to replace ManifestListFile Aug 7, 2026
…ManifestListFile

ManifestListFile and its implementation contains nothing that is specific
to manifest lists. It is more generally related to files that use
TableMetadata.encryptionKeys to store encrypted encryption key metadata
that are referred to by a key ID.
This PR introduces a more general interface that can be used accross
multiple file types like manifest lists, V4 root manifests, table
statistics and partition statistics. The less general functionality
specific to manifest lists is deprecated or removed where possible.
@gaborkaszab
gaborkaszab force-pushed the main_encryptable_file branch from 0a3b903 to c08b3fd Compare August 8, 2026 10:50

@gaborkaszab gaborkaszab left a comment

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.

Thanks for taking a look, @stevenzwu !

* A file that may be encrypted. If it is encrypted, its encrypted key metadata is tracked in the
* table metadata encryption keys and is referenced by a key ID.
*/
public interface EncryptableFile {

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.

Changed to EncryptedFile, however, I'm still not comfortable with the vile name. The name suggests the file is encrypted, but it's may or may not. Maybe FileWithEncryptedKey ?

* The file key metadata can be encrypted. Returns ID of encryption key or null if it's not
* encrypted.
*/
String encryptionKeyID();

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.

Thanks for the comment suggestion! Applied.

About the function name: I'm not sure we can change the function name, because that would break the API for ManifestListFile that is derived from this interface.
Alternatively, we can avoid deriving ManifestListFile from the new interface, but then we won't be able to cast it to the new interface and delegate to the new function signature like in FileIO or in EncryptionUtil:
newInputFile((EncryptableFile) manifestList)

/**
* A manifest list file that may be encrypted.
*
* @deprecated will be removed in 2.0.0; use {@link EncryptableFile} instead.

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 added for now, but I personally don't feel it's useful to the reader.

"Snapshot key metadata encryption requires a StandardEncryptionManager");
StandardEncryptionManager sem = (StandardEncryptionManager) em;
String manifestListKeyId = manifestList.encryptionKeyID();
String fileKeyId = file.encryptionKeyID();

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.

Renamed them

@gaborkaszab
gaborkaszab requested a review from stevenzwu August 8, 2026 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

2 participants