Skip to content

[#11138][#11137] refactor(iceberg-rest): federation handling via FederatedCatalogWrapper subclass#11367

Draft
roryqi wants to merge 3 commits into
apache:mainfrom
qqqttt123:iceberg-federated-catalog-wrapper-11138
Draft

[#11138][#11137] refactor(iceberg-rest): federation handling via FederatedCatalogWrapper subclass#11367
roryqi wants to merge 3 commits into
apache:mainfrom
qqqttt123:iceberg-federated-catalog-wrapper-11138

Conversation

@roryqi
Copy link
Copy Markdown
Contributor

@roryqi roryqi commented Jun 2, 2026

What changes were proposed in this pull request?

Federation logic in CatalogWrapperForREST was implemented as scattered
instanceof RESTCatalog / isRESTCatalog() short-circuits across the class.
This PR refactors them into polymorphic dispatch and fixes the missing
registerTable federation path:

  • Add FederatedCatalogWrapper extends CatalogWrapperForREST that overrides the
    operations needing federation-aware behavior: createTable, loadTable,
    updateTable, registerTable, and buildCatalogConfigToClients.
  • Add a CatalogWrapperForREST.create(...) factory that returns the federated
    subclass when the backend is rest, and wire IcebergCatalogWrapperManager
    to it.
  • Add registerTableInternal, mirroring loadTableInternal, so federated
    registerTable extracts FileIO-derived client config and credential fields
    from the remote catalog's table.io() (previously dropped). ([Subtask] Add federation FileIO-property-extraction to registerTable #11137)
  • Remove the now-dead instanceof/isRESTCatalog() branches from the base
    class (createTable, loadTable, updateTable, shouldGenerateCredential),
    and make buildCatalogConfigToClients an overridable instance method backed by
    a shared filterCatalogConfigForClients helper.

Why are the changes needed?

Adding a new federated operation required remembering to add a corresponding
instanceof check; nothing in the type system enforced it. The missing
registerTable federation handling was a direct bug from this pattern: a
federated registerTable returned a LoadTableResponse without the
FileIO-derived properties and credential fields that createTable/loadTable
include. Polymorphic dispatch removes the foot-gun and fixes the bug.

Fix: #11138
Fix: #11137

Does this PR introduce any user-facing change?

No. Federated registerTable responses now include the FileIO/credential client
config they should have included before; no API or property-key changes.

How was this patch tested?

./gradlew :iceberg:iceberg-rest-server:test -PskipITs (full module unit suite
green), plus new unit tests:

  • testCreateReturnsFederatedWrapperForRestBackend
  • testCreateReturnsBaseWrapperForNonRestBackend
  • testFederatedRegisterTableIncludesFileIo

Existing buildCatalogConfigToClients tests were updated to exercise the
polymorphic source selection and the shared filter helper.

🤖 Generated with Claude Code

…tedCatalogWrapper subclass

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@roryqi roryqi marked this pull request as draft June 2, 2026 13:01
@roryqi roryqi changed the title [#11138] refactor(iceberg-rest): federation handling via FederatedCatalogWrapper subclass [#11138][#11137] refactor(iceberg-rest): federation handling via FederatedCatalogWrapper subclass Jun 2, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

Code Coverage Report

Overall Project 66.81% +0.03% 🟢
Files changed 73.14% 🟢

Module Coverage
aliyun 1.72% 🔴
api 46.82% 🟢
authorization-common 85.96% 🟢
aws 3.66% 🔴
azure 2.47% 🔴
catalog-common 10.04% 🔴
catalog-fileset 80.33% 🟢
catalog-glue 66.08% 🟢
catalog-hive 79.55% 🟢
catalog-jdbc-clickhouse 80.02% 🟢
catalog-jdbc-common 45.31% 🟢
catalog-jdbc-doris 80.28% 🟢
catalog-jdbc-hologres 54.03% 🟢
catalog-jdbc-mysql 79.23% 🟢
catalog-jdbc-oceanbase 78.38% 🟢
catalog-jdbc-postgresql 82.29% 🟢
catalog-jdbc-starrocks 78.51% 🟢
catalog-kafka 77.01% 🟢
catalog-lakehouse-generic 44.89% 🟢
catalog-lakehouse-hudi 79.1% 🟢
catalog-lakehouse-iceberg 85.66% 🟢
catalog-lakehouse-paimon 79.29% 🟢
catalog-model 77.72% 🟢
cli 44.51% 🟢
client-java 77.91% 🟢
common 49.99% 🟢
core 82.49% 🟢
filesystem-hadoop3 76.97% 🟢
flink 0.0% 🔴
flink-common 41.2% 🟢
flink-runtime 0.0% 🔴
gcp 14.12% 🔴
hadoop-common 10.39% 🔴
hive-metastore-common 53.26% 🟢
iceberg-common 56.75% 🟢
iceberg-rest-server 72.52% +0.09% 🟢
idp-basic 85.99% 🟢
integration-test-common 0.0% 🔴
jobs 66.17% 🟢
lance-common 20.83% 🔴
lance-rest-server 60.27% 🟢
lineage 53.02% 🟢
optimizer 82.95% 🟢
optimizer-api 21.95% 🔴
server 85.73% 🟢
server-common 73.13% 🟢
spark 32.79% 🔴
spark-common 39.75% 🔴
trino-connector 39.44% 🔴
Files
Module File Coverage
iceberg-rest-server FederatedCatalogWrapper.java 87.5% 🟢
CatalogWrapperForREST.java 73.3% 🟢
IcebergCatalogWrapperManager.java 69.81% 🟢

roryqi and others added 2 commits June 3, 2026 13:13
…ods into FederatedCatalogWrapper

The *Internal methods (createTable/loadTable/registerTable/updateTable and
their staged-create helpers) are only invoked from the federated path, so
keep the base CatalogWrapperForREST free of federation-specific code by
relocating them into FederatedCatalogWrapper as private members. Extract a
shared buildLoadTableResponseFromFileIo helper to dedup the identical
FileIO-extraction blocks, and expose catalogPropertiesToClientKeys as
protected since the base filter helper still needs it.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…atalog-wrapper-11138

# Conflicts:
#	iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/CatalogWrapperForREST.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant