You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "xanderbailey (via GitHub)" <gi...@apache.org> on 2026/01/16 10:11:10 UTC
[I] Encryption - `InputFile`, `OutputFile` should be enums? [iceberg-rust]
xanderbailey opened a new issue, #2036:
URL: https://github.com/apache/iceberg-rust/issues/2036
### Is your feature request related to a problem or challenge?
## Idiomatic Rust Design for `InputFile` with Encryption Support
While researching the encryption project, I've noticed we need to make some design decisions where we can't exactly follow the current Java implementation and need to make things more idiomatic for Rust.
One key example is `InputFile`. In Java, this is an interface that allows for implementations like `NativeEncryptionInputFile`. In Rust, the idiomatic way to represent this polymorphism is through an enum rather than trait objects.
### Proposed Design
I have a rough draft that refactors `InputFile` from a single struct to an enum with variants:
```rust
/// A file input, either encrypted or unencrypted.
pub enum InputFile {
/// Encrypted file input
NativeEncryption(NativeEncryptedInputFile),
/// Unencrypted file input
Unencrypted(UnencryptedInputFile),
}
/// Unencrypted file input
#[derive(Debug)]
pub struct UnencryptedInputFile {
op: Operator,
path: String,
relative_path_pos: usize,
}
/// Encrypted file input
#[derive(Debug)]
pub struct NativeEncryptedInputFile {
op: Operator,
path: String,
relative_path_pos: usize,
// Add encryption-specific fields here, e.g.:
// key: EncryptionKey,
}
```
The public API methods delegate to the appropriate variant:
```rust
impl InputFile {
pub fn location(&self) -> &str {
match self {
InputFile::NativeEncryption(f) => f.location(),
InputFile::Unencrypted(f) => f.location(),
}
}
pub async fn read(&self) -> crate::Result<Bytes> {
match self {
InputFile::NativeEncryption(f) => f.read().await,
InputFile::Unencrypted(f) => f.read().await,
}
}
// ... other methods follow the same pattern
}
```
### Benefits
1. **Zero-cost abstraction** - No vtable overhead like with `dyn` trait objects
2. **Exhaustive pattern matching** - Compiler ensures all variants are handled
3. **Clear type representation** - Encryption state is encoded in the type system
4. **Easy to extend** - Adding new variants (e.g., `Compressed`?) is straightforward
### Trade-offs
This is actually a relatively small code change but provides a foundation for extending `InputFile` capabilities while maintaining Rust idioms. The main consideration is that this approach is more explicit than Java's interface-based design, but that explicitness is generally considered a strength in Rust.
### Related Work
This pattern is similar to how we might handle readers, where we also need an enum wrapper to avoid `Box<dyn FileReader>`:
```rust
pub enum InputFileReader {
Encrypted(opendal::Reader),
Unencrypted(opendal::Reader),
}
```
Would appreciate feedback on this approach before proceeding with full implementation.
### Describe the solution you'd like
_No response_
### Willingness to contribute
None
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [I] Encryption - `InputFile`, `OutputFile` should be enums? [iceberg-rust]
Posted by "CTTY (via GitHub)" <gi...@apache.org>.
CTTY commented on issue #2036:
URL: https://github.com/apache/iceberg-rust/issues/2036#issuecomment-3780304128
I expect it to be complete in about a month. please use #2058 to track the removal of Extensions
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [I] Encryption - `InputFile`, `OutputFile` should be enums? [iceberg-rust]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #2036:
URL: https://github.com/apache/iceberg-rust/issues/2036#issuecomment-5028801677
This issue has been automatically marked as stale because it has been open for 180 days with no activity. It will be closed in next 14 days if no further activity occurs. To permanently prevent this issue from being considered stale, add the label 'not-stale', but commenting on the issue is preferred when possible.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [I] Encryption - `InputFile`, `OutputFile` should be enums? [iceberg-rust]
Posted by "xanderbailey (via GitHub)" <gi...@apache.org>.
xanderbailey commented on issue #2036:
URL: https://github.com/apache/iceberg-rust/issues/2036#issuecomment-5493218779
We decided to go a different direction with encryption so this issue isn't needed anymore.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [I] Encryption - `InputFile`, `OutputFile` should be enums? [iceberg-rust]
Posted by "xanderbailey (via GitHub)" <gi...@apache.org>.
xanderbailey closed issue #2036: Encryption - `InputFile`, `OutputFile` should be enums?
URL: https://github.com/apache/iceberg-rust/issues/2036
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [I] Encryption - `InputFile`, `OutputFile` should be enums? [iceberg-rust]
Posted by "xanderbailey (via GitHub)" <gi...@apache.org>.
xanderbailey commented on issue #2036:
URL: https://github.com/apache/iceberg-rust/issues/2036#issuecomment-3759233749
Any thoughts @mbutrovich
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [I] Encryption - `InputFile`, `OutputFile` should be enums? [iceberg-rust]
Posted by "CTTY (via GitHub)" <gi...@apache.org>.
CTTY commented on issue #2036:
URL: https://github.com/apache/iceberg-rust/issues/2036#issuecomment-3775312702
An enum seems like a good idea.
Listing out some potential alternatives from the top of my mind:
- Add encryption-aware `FileWrite` and `FileRead` implementations
- Push encryption logic fully to the upcoming `Storage` trait
this design decision also depends on how we plan to create `Input`/`OutputFile`. Do you think we will have an `EncryptionManager` in rust and where does that live?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [I] Encryption - `InputFile`, `OutputFile` should be enums? [iceberg-rust]
Posted by "xanderbailey (via GitHub)" <gi...@apache.org>.
xanderbailey commented on issue #2036:
URL: https://github.com/apache/iceberg-rust/issues/2036#issuecomment-3776797678
Are there rough timelines for that change do you know?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [I] Encryption - `InputFile`, `OutputFile` should be enums? [iceberg-rust]
Posted by "xanderbailey (via GitHub)" <gi...@apache.org>.
xanderbailey commented on issue #2036:
URL: https://github.com/apache/iceberg-rust/issues/2036#issuecomment-3775427401
I had a go at implementing the `EncryptionManager` as an `Extension` in `FileIo` to try and keep the flow aligned with Java and that seems to work okay but I didn't follow through with the whole implementation so it's very possible this approach is incorrect.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [I] Encryption - `InputFile`, `OutputFile` should be enums? [iceberg-rust]
Posted by "CTTY (via GitHub)" <gi...@apache.org>.
CTTY commented on issue #2036:
URL: https://github.com/apache/iceberg-rust/issues/2036#issuecomment-3775917292
I think using Extension for now is fine. But please note Extensions will be removed once we made Storage a trait. You may need to move your encryption there to a customized Storage
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org