Skip to content

[#13330] feat(core): validate catalog properties together at catalog create and alter - #13333

Open
nevzheng wants to merge 3 commits into
apache:mainfrom
nevzheng:feat/13330-validate-catalog-properties
Open

nevzheng wants to merge 3 commits into
apache:mainfrom
nevzheng:feat/13330-validate-catalog-properties

Conversation

@nevzheng

Copy link
Copy Markdown
Collaborator

Stacked on #13331 and #13332: please review only the last commit.

What changes were proposed in this pull request?

Add a PropertiesMetadata.validateProperties(Map) hook for rules that relate several properties, which a single property entry's decoder cannot check. The default does nothing.

PropertiesMetadataHelpers calls it at catalog create with the requested properties, and at catalog alter with the stored properties plus the change. CatalogManager passes the stored properties to the alter check.

The Iceberg catalog implements the hook for the table-format-version properties from #13331. A table-format-version.default above table-format-version.max, or a conflicting table-default.format-version, now fails the create or alter request, and the catalog keeps its properties. The load-time check from #13331 stays for catalogs stored earlier: they load, but every schema and table operation fails with HTTP 400 until an alter fixes them.

Why are the changes needed?

Without this, an invalid combination is accepted, stored, and only fails on the catalog's first operation, which leaves a broken catalog behind. Checking at create and alter makes the misconfiguration visible to the operator who made it.

Fix: #13330

Does this PR introduce any user-facing change?

  • A catalog create or alter with an invalid table-format-version combination now fails with HTTP 400 instead of storing a catalog whose operations fail. docs/lakehouse-iceberg-catalog.md is updated.
  • A new default method, PropertiesMetadata.validateProperties, for connector authors. Existing implementations are unaffected.

How was this patch tested?

Unit tests only. This PR covers the last row of the format-version coverage (the others are in #13331 and #13332):

Case Gravitino API Iceberg REST service
Default above max, or conflicting table-default.format-version, at catalog create and alter refused, catalog unchanged n/a: catalogs are managed through the Gravitino API

New unit tests in TestPropertiesMetadataHelpers and TestCatalogManager cover the hook at create and at alter with the change applied. TestIcebergCatalogPropertiesMetadata covers the Iceberg rules.

./gradlew :core:test :catalogs:catalog-common:test :catalogs:catalog-lakehouse-iceberg:test :iceberg:iceberg-common:test :iceberg:iceberg-rest-server:test -PskipITs: 2960 tests, 0 failures, 0 errors, 2 skipped (core 2249 with 2 skipped, catalog-common 40, catalog-lakehouse-iceberg 125, iceberg-common 83, iceberg-rest-server 463).

…x catalog properties

Add the table-format-version.default and table-format-version.max catalog
properties so operators can choose the format version of new tables that do
not request one and cap the version tables may be created at. Both are
validated as supported Iceberg versions (1-4), default to 2 and 4, and a
conflicting table-default.format-version fails catalog initialization.

A format-version above 4, the highest this Gravitino build accepts, is now
refused as unsupported by this Gravitino (supports 1-4) rather than as
exceeding an unset table-format-version.max. The Gravitino API's table
property validation reports the same message as its cause.

A guard test fails when the ceiling and the bundled Iceberg's
TableMetadata.SUPPORTED_TABLE_FORMAT_VERSION differ, so an Iceberg upgrade
forces a review of the ceiling.

Pin what a stored catalog with table-format-version.default above .max
does: it loads as metadata, and its first schema or table operation fails
with an IllegalArgumentException (HTTP 400) naming both properties.

Docs: drop the upgrade clause from this layer (the Iceberg REST catalog
adds it) and state the ceiling and the load-time behaviour.
…n the Iceberg REST catalog

Apply table-format-version.default and table-format-version.max in the Iceberg
REST service: a stage-create without format-version gets the catalog default,
and create, stage-create and upgrade-format-version commits above the maximum
fail with 400. Static catalogs are validated at startup, and catalogs with the
rest backend are exempt because they forward requests unchanged.

A federated catalog no longer reads table-format-version.max at all, so a
value that would not parse (for example max=abc) neither stops it from
loading nor keeps a request from reaching the remote catalog.

Cover the build's ceiling on the Iceberg REST catalog: with the maximum
unset, format-version 5 on create, stage-create, upgrade-format-version and
a staged-create commit is refused with HTTP 400 and the ceiling message,
and nothing is created or changed.

Docs: add the upgrade clause to the catalog doc now that the Iceberg REST
service enforces it, and state the ceiling in the REST service doc.
…talog create and alter

Add a PropertiesMetadata.validateProperties hook for rules that relate several
properties, and call it from PropertiesMetadataHelpers at catalog create and,
with the change applied to the stored properties, at catalog alter. The Iceberg
catalog uses it so an invalid table-format-version combination is refused when
the catalog is created or altered instead of when it loads.
@github-actions

Copy link
Copy Markdown

Code Coverage Report

Overall Project 70.82% +0.29% 🟢
Files changed 83.5% 🟢

Module Coverage
aliyun 19.74% 🔴
api 52.15% 🟢
authorization-common 85.96% 🟢
authorization-ranger 14.44% 🔴
aws 53.54% 🟢
aws-bundle 0.0% 🔴
azure 32.1% 🔴
azure-bundle 0.0% 🔴
catalog-common 32.17% +11.71% 🔴
catalog-fileset 82.28% 🟢
catalog-glue 71.52% 🟢
catalog-hive 83.08% 🟢
catalog-jdbc-common 45.72% 🟢
catalog-jdbc-doris 84.56% 🟢
catalog-jdbc-mysql 81.8% 🟢
catalog-jdbc-postgresql 83.89% 🟢
catalog-jdbc-starrocks 79.16% 🟢
catalog-kafka 75.21% 🟢
catalog-lakehouse-generic 64.4% 🟢
catalog-lakehouse-hudi 79.1% 🟢
catalog-lakehouse-iceberg 86.25% -0.41% 🟢
catalog-lakehouse-paimon 84.31% 🟢
catalog-model 77.99% 🟢
cli 44.62% 🟢
client-java 78.46% 🟢
common 58.21% 🟢
core 84.96% -0.27% 🟢
filesystem-hadoop3 76.48% 🟢
flink 18.07% 🔴
flink-common 53.95% 🟢
flink-runtime 0.0% 🔴
gcp 32.2% 🔴
hadoop-auth 68.0% 🟢
hadoop-common 17.84% 🔴
hive-metastore-common 54.41% 🟢
iceberg-aliyun-bundle 0.0% 🔴
iceberg-common 66.56% +9.02% 🟢
iceberg-rest-server 77.37% +0.95% 🟢
idp-basic 86.77% 🟢
integration-test-common 0.0% 🔴
jobs 59.96% 🟢
lance-common 36.14% 🔴
lance-rest-server 69.51% 🟢
lineage 59.39% 🟢
optimizer 83.33% 🟢
optimizer-api 42.56% 🟢
server 90.24% 🟢
server-common 82.37% 🟢
spark 60.5% 🟢
tencent 81.78% 🟢
trino-connector 61.99% 🟢
Files
Module File Coverage
catalog-common IcebergPropertiesUtils.java 85.38% 🟢
IcebergConstants.java 80.0% 🟢
catalog-lakehouse-iceberg IcebergTablePropertiesMetadata.java 100.0% 🟢
IcebergCatalogPropertiesMetadata.java 98.51% 🟢
IcebergTable.java 89.89% 🟢
IcebergCatalogOperations.java 79.74% 🟢
core PropertiesMetadataHelpers.java 100.0% 🟢
PropertiesMetadata.java 81.58% 🟢
CatalogManager.java 75.3% 🟢
iceberg-common IcebergConfig.java 99.63% 🟢
iceberg-rest-server IcebergCatalogWrapperManager.java 92.22% 🟢
StaticIcebergConfigProvider.java 90.0% 🟢
CatalogWrapperForREST.java 83.61% 🟢

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Improvement] Let operators set the default and maximum Iceberg table format version per catalog

1 participant