[#11017] improvement(clickhouse): Support date partition transforms#11018
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds support in the ClickHouse JDBC catalog for rendering Gravitino date-based partition transforms into ClickHouse PARTITION BY expressions during table creation, aligning create-table behavior with the existing SHOW CREATE TABLE parsing support.
Changes:
- Extend ClickHouse partition expression rendering to support
year,month, anddaytransforms (toYear,toYYYYMM,toDate). - Remove the stale identity-only partition helper from
ClickHouseTableOperationsand route partition rendering through the shared SQL utility. - Add/adjust unit and integration tests to validate create + load roundtrip with month partitioning.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| catalogs-contrib/catalog-jdbc-clickhouse/src/main/java/org/apache/gravitino/catalog/clickhouse/operations/ClickHouseTableSqlUtils.java | Implement year/month/day partition transform rendering and centralize single-column validation. |
| catalogs-contrib/catalog-jdbc-clickhouse/src/main/java/org/apache/gravitino/catalog/clickhouse/operations/ClickHouseTableOperations.java | Remove local partition-expression helper; use shared SQL utility for PARTITION BY rendering. |
| catalogs-contrib/catalog-jdbc-clickhouse/src/test/java/org/apache/gravitino/catalog/clickhouse/operations/TestClickHouseTableOperations.java | Add unit assertions for PARTITION BY toYear/toYYYYMM/toDate generation. |
| catalogs-contrib/catalog-jdbc-clickhouse/src/test/java/org/apache/gravitino/catalog/clickhouse/integration/test/CatalogClickHouseIT.java | Update integration test to create/load a table using month(event_time) partitioning and assert the loaded transform. |
Code Coverage Report
Files
|
…g and broaden test coverage - Collapse the if-else chain in `toPartitionExpression` into a switch expression; the default branch now subsumes the previous `isSupportedPartitionTransform` guard. - Reword the misleading "single column partitioning" precondition; ClickHouse does support multi-column partitions via tuple(), the real constraint is per-transform. - Add identity / year / day round-trip integration coverage so the refactor in #11017 does not drop the original identity path. - Add a tuple multi-transform unit test to lock the `tuple(toYear(c1), toDate(c1))` output. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
Support ClickHouse table creation with Gravitino date partition transforms:
Transforms.year(column)->PARTITION BY toYear(column)Transforms.month(column)->PARTITION BY toYYYYMM(column)Transforms.day(column)->PARTITION BY toDate(column)This PR also removes the stale identity-only helper in
ClickHouseTableOperationsand uses the shared ClickHouse SQL utility path for partition expression rendering.Why are the changes needed?
ClickHouse catalog table creation previously only supported identity partitioning, while loading existing ClickHouse tables already recognized
toYear,toYYYYMM, andtoDatepartition expressions.Fix: #11017
Does this PR introduce any user-facing change?
Yes. Users can now create ClickHouse MergeTree-family tables with
year,month, anddaypartition transforms through Gravitino.How was this patch tested?