jiangxt2 opened a new pull request, #12765: URL: https://github.com/apache/gravitino/pull/12765
### What changes were proposed in this pull request? This pull request aggregates the ClickHouse primary-key metadata rows returned by `ClickHouseTableOperations.getIndexes()` before constructing Gravitino indexes. Rows are grouped by the synthetic primary-key name and ordered by `KEY_SEQ`, so `PRIMARY KEY (id, ts)` is loaded as one `PRIMARY_KEY` index whose fields are `[[id], [ts]]` instead of two independent single-column indexes. The implementation rejects null, non-positive, or duplicate key sequence values, while allowing positive sequence gaps because their relative order remains unambiguous. Existing single-column primary keys and data-skipping index loading remain unchanged. The patch also adds direct unit coverage for grouping, ordering, invalid sequence metadata, single-column behavior, and secondary-index compatibility, plus a focused real ClickHouse create-load round-trip test for a two-column primary key. ### Why are the changes needed? The ClickHouse JDBC driver does not expose primary keys through `DatabaseMetaData.getPrimaryKeys`, so the connector reads `system.tables.primary_key` and returns one metadata row per key column. The current implementation immediately converts each row into a separate Gravitino index and ignores `KEY_SEQ`, which loses the identity and field order of a composite primary key. Aggregating these rows restores the same composite-index contract used by the common JDBC metadata path without changing public APIs, primary-key DDL generation, or data-skipping index parsing. Fix: #12748 ### Does this PR introduce _any_ user-facing change? Yes. Loading a ClickHouse table with a composite primary key now returns one ordered Gravitino `PRIMARY_KEY` index instead of multiple single-column indexes with the same name. Single-column primary keys are unchanged, and no public API or property key is added or removed. ### How was this patch tested? - `./gradlew :catalogs-contrib:catalog-jdbc-clickhouse:spotlessCheck --console=plain` — passed. - `./gradlew rat --console=plain` — passed. - `./gradlew :catalogs-contrib:catalog-jdbc-clickhouse:test -PskipITs --console=plain` — passed; `TestClickHouseTableOperationsUnit` reported 34 tests, zero skipped, failures, or errors. - `./gradlew :catalogs-contrib:catalog-jdbc-clickhouse:build -x test --console=plain` — passed. - `./gradlew :catalogs-contrib:catalog-jdbc-clickhouse:test --tests 'org.apache.gravitino.catalog.clickhouse.integration.test.CatalogClickHouseIT.testCreateAndLoadCompositePrimaryKey' -PskipDockerTests=false --console=plain --no-daemon` — passed against ClickHouse 24.8.14 with tests=1, skipped=0, failures=0, errors=0. - `./gradlew :catalogs-contrib:catalog-jdbc-clickhouse:test --tests 'org.apache.gravitino.catalog.clickhouse.integration.test.CatalogClickHouseClusterIT' -PskipDockerTests=false --console=plain --no-daemon` — passed against ClickHouse 24.8.14 with tests=18, skipped=0, failures=0, errors=0. - A ClickHouse 25.3.2.39 characterization query confirmed that a native `PRIMARY KEY (id, ts)` produces metadata rows `id/1` and `ts/2`. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
