Skip to content

[Cherry-pick to branch-1.3] [#11879] fix(clickhouse): fix type conversion for Decimal, DateTime64, LowCardinality, and IPv4/IPv6 (#11884)#11894

Merged
yuqi1129 merged 1 commit into
branch-1.3from
cherry-pick-b096dd2c-to-branch-1.3
Jul 4, 2026
Merged

[Cherry-pick to branch-1.3] [#11879] fix(clickhouse): fix type conversion for Decimal, DateTime64, LowCardinality, and IPv4/IPv6 (#11884)#11894
yuqi1129 merged 1 commit into
branch-1.3from
cherry-pick-b096dd2c-to-branch-1.3

Conversation

@github-actions

@github-actions github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown

Cherry-pick Information:

  • Original commit: b096dd2
  • Target branch: branch-1.3
  • Status: ✅ Clean cherry-pick (no conflicts)

…, LowCardinality, and IPv4/IPv6 (#11884)

### What changes were proposed in this pull request?

Fix four type conversion issues in the ClickHouse catalog's
`ClickHouseTypeConverter`:

1. **Decimal(precision > 38) → ExternalType**: ClickHouse supports
Decimal up to precision 76
(Decimal128/Decimal256), but Gravitino core `DecimalType` enforces
precision ≤ 38. Tables with
`Decimal(50, 10)` etc. previously threw `IllegalArgumentException` on
`loadTable`. Now mapped to
`ExternalType` for precision > 38, consistent with the existing pattern
for non-standard types.

2. **DateTime64(N) precision preserved on round-trip**:
`TypeUtils.extractDateTimePrecision()`
regex did not match `DateTime64(3)` — the entire type fell through to
`ExternalType`. Extended
the regex to `^DateTime(?:64)?\((\d+)\)$`. In `fromGravitino`,
`TimestampType` with
   precision > 0 now returns `DateTime64(N)` instead of bare `DateTime`.

3. **LowCardinality wrapper stripped before Nullable**: For
`LowCardinality(Nullable(String))`, the outermost wrapper is
`LowCardinality`. Added
`TypeUtils.stripLowCardinality()` and call it before `stripNullable()`
in `toGravitino()`.

4. **IPv4/IPv6 mapped to ExternalType**: Constants `IPV4` and `IPV6`
were declared but had no
`case` branches. Added `case IPV4:` / `case IPV6:` returning
`ExternalType.of(...)`.

### Why are the changes needed?

Fix: #11879

These issues cause ClickHouse tables with common column types
(Decimal(50,x), DateTime64,
LowCardinality, IPv4/IPv6) to either crash on `loadTable` or lose type
semantics on round-trip.

### Does this PR introduce _any_ user-facing change?

Yes. Tables with Decimal(precision > 38), DateTime64(N),
LowCardinality(Nullable(...)),
IPv4, or IPv6 columns can now be loaded without errors. Type round-trip
fidelity is improved.

### How was this patch tested?

- New unit tests in `TestClickHouseTypeConverter`: `./gradlew
:catalogs-contrib:catalog-jdbc-clickhouse:test -PskipITs`
(7 test scenarios: 4 toGravitino assertions — IPv6, DateTime64(3),
LowCardinality(Nullable(String)),
Decimal(50,10); 3 fromGravitino direction checks — DateTime64(3), IPv4,
IPv6)
- Updated existing Docker IT assertion in
`TestClickHouseTableOperations.testTypeConversionAgainstCluster`:
`c_dt64` column type changed from `ExternalType.of("DateTime64(3)")` to
`TimestampType.withoutTimeZone(3)`
  to match the new `toGravitino()` behavior
- Docker integration tests: `./gradlew
:catalogs-contrib:catalog-jdbc-clickhouse:test -PskipDockerTests=false
--tests "TestClickHouseTableOperations"`

Signed-off-by: jiangxt2 <jiangxt2@vip.qq.com>
@github-actions github-actions Bot requested a review from jerryshao July 3, 2026 11:40
@yuqi1129 yuqi1129 merged commit 2e6d713 into branch-1.3 Jul 4, 2026
34 checks passed
@yuqi1129 yuqi1129 deleted the cherry-pick-b096dd2c-to-branch-1.3 branch July 4, 2026 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants