[#39723] Implement model for Iceberg side input cache - #39724
Conversation
|
Assigning reviewers: R: @Abacn for label java. Note: If you would like to opt out of this review, comment Available commands:
The PR bot will only process comments in the main thread (not review comments). |
| .setSortOrderJson(SortOrderParser.toJson(table.sortOrder())) | ||
| .setProperties(table.properties()) | ||
| .build(); | ||
| } |
There was a problem hiding this comment.
Also include fileIO json here. Iceberg has a FileIOParser that works similarly to the other properties
| public SideInputTable(SerializableTableSpec spec, FileIO fileIO) { | ||
| this(spec, fileIO, PlaintextEncryptionManager.instance()); | ||
| } |
There was a problem hiding this comment.
Should be able to remove the FileIO arg when we serialize it in the tableSpec
| public abstract String getPartitionSpecJson(); | ||
|
|
||
| @SchemaFieldNumber("6") | ||
| public abstract String getSortOrderJson(); |
There was a problem hiding this comment.
I think we should keep track of the full map of schemas / partition specs / sort orders. There are instances where we're not always working with the most recent table metadata, so we'll need to have access to historical schema/spec/sort orders.
Might make sense to add 3 int fields to indicate the "current" schemaId, specId, orderId, and use them to return the respective metadata property.
| @Override | ||
| public Map<Integer, PartitionSpec> specs() { | ||
| return Collections.singletonMap(spec.getPartitionSpec().specId(), spec.getPartitionSpec()); | ||
| } |
There was a problem hiding this comment.
Following from previous comment. We have instances where we want to access historical partition specs. So this should contain more than just the current spec. Same goes for schemas() and sortOrders()
|
|
||
| @Override | ||
| public void refresh() { | ||
| // No-op: refresh is managed by the periodic side-input update mechanism |
There was a problem hiding this comment.
Can we throw an UnsupportedOperationException for all of these unsupported methods?
Better to let us know where we're incorrectly using SerializableTableSpec, and instead opt into using a real table
| .setSortOrderJson(SortOrderParser.toJson(table.sortOrder())) | ||
| .setProperties(table.properties()) | ||
| .build(); | ||
| } |
There was a problem hiding this comment.
I think we can also serialize properties to reconstruct the EncryptionManager, instead of making it an arg for SideInputTable. Mostly because we won't have access to the EncryptionManager on the worker side to properly create SideInputTable
When loading the real table, we can serialize and store the encrypted keys in SeiralizableTableSpec:
TableMetadata metadata = ((HasTableOperations) table).operations().current();
List<String> encryptedKeyJsons =
metadata.encryptionKeys().stream()
.map(key -> EncryptedKeyParser.toJson(key, false))
.collect(Collectors.toList());
(AFAICT, we can assume the table implements HasTableOperations. Let's throw if not)
Then to reconstruct it in SideInputTable:
List<EncryptedKey> encryptedKeys =
encryptedKeyJsons.stream()
.map(EncryptedKeyParser::fromJson)
.collect(Collectors.toList());
EncryptionManager encryption;
if (!properties.containsKey(TableProperties.ENCRYPTION_TABLE_KEY)) {
encryption = PlaintextEncryptionManager.instance();
} else {
KeyManagementClient kmsClient = EncryptionUtil.createKmsClient(catalogProperties);
encryption = EncryptionUtil.createEncryptionManager(encryptedKeys, properties, kmsClient);
}
return encryption;
We'd probably need to pass catalogProperties (from IcebergCatalogConfig) to SideInputTable's constructor.
Implements the SerializableTableSpec and SideInputTable classes to provide a serializable representation of Iceberg table metadata + corresponding tests.
Part of #39723
Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, commentfixes #<ISSUE NUMBER>instead.CHANGES.mdwith noteworthy changes.See the Contributor Guide for more tips on how to make review process smoother.
To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md
GitHub Actions Tests Status (on master branch)
See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.