jiangxt2 opened a new pull request, #12275:
URL: https://github.com/apache/gravitino/pull/12275

   ### What changes were proposed in this pull request?
   
   1. **Date32 → DateType**: Add `case DATE32` in 
`ClickHouseTypeConverter.toGravitino()`, mapping ClickHouse Date32 to Gravitino 
`Types.DateType`. Previously Date32 fell through to the default branch and was 
mapped to `ExternalType`, despite being a calendar date type semantically 
identical to Date (just with a wider year range: 1900–2299 vs 1970–2149).
   
   2. **Enum IT test**: Add `testEnumRoundTrip()` integration test verifying 
that Enum8/Enum16 round-trip correctly through the Gravitino type system via 
ExternalType. The enum definitions (including spaces and equals signs) are 
fully preserved across create → load → recreate cycles.
   
   ### Why are the changes needed?
   
   Date32 was the last user-visible ClickHouse type that has a Gravitino native 
counterpart (`Types.DateType`) but was not mapped to it. The `DateTime64(3)` → 
`TimestampType.withoutTimeZone(3)` → `DateTime(0)` pattern already establishes 
the precedent of one-way precision/range narrowing in the ClickHouse converter 
— Date32 follows the same pattern.
   
   Enum8/Enum16 already work correctly via ExternalType pass-through, but had 
no integration test coverage, leaving a gap in verifying their round-trip 
correctness. The test confirms no code change is needed for Enum support.
   
   Fix: #12272
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes, with a caveat. After this change:
   - **Read path**: ClickHouse `Date32` columns are now loaded as Gravitino 
`DateType` (instead of `ExternalType("Date32")`)
   - **Write path**: `DateType` is still mapped to ClickHouse `Date` (not 
`Date32`), so round-tripping a Date32 table through Gravitino will produce 
`Date` on the ClickHouse side, narrowing the supported year range from 
1900–2299 to 1970–2149
   
   This is consistent with the existing `DateTime64(3)` → `DateTime(0)` 
precision narrowing pattern. Users who need the full 1900–2299 range should use 
ExternalType explicitly when creating tables.
   
   ### How was this patch tested?
   
   - Unit tests: `TestClickHouseTypeConverter` — verified Date32 now maps to 
`DateType.get()` (previously `ExternalType.of("Date32")`)
   - Docker integration tests: `CatalogClickHouseIT.testEnumRoundTrip` — 
verified Enum8/Enum16 round-trip correctness (create → load → verify → recreate 
→ SHOW CREATE TABLE) against ClickHouse 25.3.2.39
   - Static checks: `spotlessCheck`, `rat` (license headers), 
`gravitino-pr-precheck.py` — all passed
   


-- 
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]

Reply via email to