Skip to content

Add support for table encryption in Iceberg#28905

Closed
ebyhr wants to merge 1 commit into
trinodb:masterfrom
ebyhr:ebi/iceberg-encryption
Closed

Add support for table encryption in Iceberg#28905
ebyhr wants to merge 1 commit into
trinodb:masterfrom
ebyhr:ebi/iceberg-encryption

Conversation

@ebyhr
Copy link
Copy Markdown
Member

@ebyhr ebyhr commented Mar 28, 2026

Description

Fixes #28204

Release notes

## Iceberg
* Add support for table encryption. ({issue}`28204`)

@cla-bot cla-bot Bot added the cla-signed label Mar 28, 2026
@github-actions github-actions Bot added the iceberg Iceberg connector label Mar 28, 2026
@ebyhr
Copy link
Copy Markdown
Member Author

ebyhr commented Mar 28, 2026

I simply restored #28354. This PR isn't ready for reviews for now.

@findepi
Copy link
Copy Markdown
Member

findepi commented Mar 30, 2026

cc @sopel39

@wendigo
Copy link
Copy Markdown
Contributor

wendigo commented Mar 30, 2026

Can we use ConnectorTableCredentials to carry over these encryption keys?

@sopel39 sopel39 self-requested a review April 1, 2026 18:12
Co-Authored-By: kamijin_fanta <kamijin@live.jp>
@ebyhr ebyhr force-pushed the ebi/iceberg-encryption branch from 9227282 to eb017f4 Compare April 6, 2026 08:30
}
}

private static Map<String, String> fileIoProperties(Table table)
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.

nit: inline this method?

@Override
public Map<String, String> fileIoProperties()
{
return fileIo.properties();
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.

Why not io().properties()? Some comment would be useful.

private static TrinoInputFile newInputFile(TrinoFileSystem fileSystem, DeleteFile deleteFile, Optional<EncryptionManager> encryptionManager)
{
if (encryptionManager.isPresent() && deleteFile.keyMetadata() != null) {
return fileSystem.newInputFile(Location.of(deleteFile.location()));
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.

nit: add comment why this branch doesn't have file size in bytes

DeleteFile deleteFile,
Optional<EncryptionManager> encryptionManager)
{
if (encryptionManager.isEmpty() || deleteFile.keyMetadata() == null) {
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.

better to throw if key medata is not null, but encryption manager is empty. Otherwise, weird serde errors might occur


OptionalLong rowPositionLowerBound = lowerBoundPosition == null ?
OptionalLong.empty() : OptionalLong.of(Conversions.fromByteBuffer(DELETE_FILE_POS.type(), lowerBoundPosition));

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.

undo

{
return INSTANCE_SIZE
+ estimatedSizeOf(path)
+ encryptionKeyMetadata.map(value -> sizeOf(value)).orElse(0L)
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.

optional still takes space, should use io.airlift.slice.SizeOf#OPTIONAL_INSTANCE_SIZE

writeDeletes(rowsToDelete);
writer.commit();

long fileSizeInBytes = writer.getWrittenBytes();
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.

writer might be IcebergParquetFileWriter. However Trino native parquet writer doesn't support encryption. Should we skip encrypted insert path for now?

import static io.trino.spi.StandardErrorCode.NOT_SUPPORTED;
import static java.util.Objects.requireNonNull;

public class IcebergEncryptionManagerFactory
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.

Let's make it an interface. It will be easier to adopt in different environments.

return catalogKmsClient;
}
Map<String, String> properties = new HashMap<>(kmsProperties);
// Iceberg 1.10.x does not support encryption.kms-type yet, so set the KMS impl explicitly.
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.

should we target 1.11 instead?

import static java.util.Objects.checkFromIndexSize;
import static java.util.Objects.requireNonNull;

public class EncryptedTrinoInput
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.

This is only required for non-parquet encrypted files, right?

.orElse(toCompressionCodec(hiveCompressionOption));

return new IcebergParquetFileWriter(
IcebergFileWriter writer = new IcebergParquetFileWriter(
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.

native Parquet writer doesn't support encryption.

@ebyhr
Copy link
Copy Markdown
Member Author

ebyhr commented Apr 13, 2026

Superseded by #28389

@ebyhr ebyhr closed this Apr 13, 2026
@ebyhr ebyhr deleted the ebi/iceberg-encryption branch April 13, 2026 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

[Iceberg] Add Support for Iceberg Native Encryption (Client-side Table Encryption)

4 participants