Skip to content

[#39723] Implement model for Iceberg side input cache - #39724

Open
jrmccluskey wants to merge 1 commit into
apache:masterfrom
jrmccluskey:feat/iceberg-side-input-table-cache-pr1
Open

[#39723] Implement model for Iceberg side input cache#39724
jrmccluskey wants to merge 1 commit into
apache:masterfrom
jrmccluskey:feat/iceberg-side-input-table-cache-pr1

Conversation

@jrmccluskey

@jrmccluskey jrmccluskey commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

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:

  • Mention the appropriate issue in your description (for example: 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, comment fixes #<ISSUE NUMBER> instead.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

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)

Build python source distribution and wheels
Python tests
Java tests
Go tests

See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.

@github-actions

Copy link
Copy Markdown
Contributor

Assigning reviewers:

R: @Abacn for label java.

Note: If you would like to opt out of this review, comment assign to next reviewer.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

.setSortOrderJson(SortOrderParser.toJson(table.sortOrder()))
.setProperties(table.properties())
.build();
}

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.

Also include fileIO json here. Iceberg has a FileIOParser that works similarly to the other properties

Comment on lines +82 to +84
public SideInputTable(SerializableTableSpec spec, FileIO fileIO) {
this(spec, fileIO, PlaintextEncryptionManager.instance());
}

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.

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();

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.

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());
}

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.

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

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.

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();
}

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.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants