jiangxt2 opened a new issue, #11910:
URL: https://github.com/apache/gravitino/issues/11910
### Version
main branch
### Describe what's wrong
The ClickHouse catalog has two categories of issues:
**1. GraphiteMergeTree incorrectly classified as not requiring ORDER BY**
In `ClickHouseTablePropertiesMetadata`, the `GRAPHITEMERGETREE` engine
constant uses the single-argument constructor, which sets
`requireOrderBy=false` and `acceptPartition=false`. All six sibling
MergeTree-family engines (`MERGETREE`, `REPLACINGMERGETREE`,
`SUMMINGMERGETREE`, `AGGREGATINGMERGETREE`, `COLLAPSINGMERGETREE`,
`VERSIONEDCOLLAPSINGMERGETREE`) use the three-argument constructor `(value,
true, true)`.
Because `requireOrderBy=false`, the write path (`appendOrderBy`) throws
`UnsupportedOperationException("ORDER BY clause is not supported for engine:
GraphiteMergeTree")` when creating a GraphiteMergeTree table with an ORDER BY
clause. And because ClickHouse itself requires ORDER BY for MergeTree-family
engines, omitting it is also rejected by the server. **This means
GraphiteMergeTree tables cannot be created through Gravitino at all.**
**2. Multiple types fall through to ExternalType due to missing switch
cases**
`ClickHouseTypeConverter` defines constants for several types but the
`toGravitino` switch lacks corresponding `case` branches. All fall through to
the default `ExternalType`:
| Type | Constant | Impact |
|------|----------|--------|
| Enum8/Enum16 | `ENUM = "Enum"` | ClickHouse always normalizes `Enum` to
`Enum8`; the string `"Enum8(...)"` never matches the `"Enum"` case |
| Int128/Int256 | `INT128`, `INT256` | Wide integer columns become opaque
ExternalType |
| UInt128/UInt256 | `UINT128`, `UINT256` | Same as above |
| BFloat16 | `BFLOAT16` | Google Brain 16-bit float (ML inference) becomes
opaque ExternalType |
This follows the same pattern as #11879 (IPv4/IPv6/LowCardinality), fixed by
#11884 in `ClickHouseTypeConverter`.
### How to reproduce
**GraphiteMergeTree (create path):**
```java
catalog.asTableCatalog().createTable(
NameIdentifier.of("db_name", "t_graphite"),
new Column[] { Column.of("id", Types.LongType.get(), false) },
"comment",
Map.of("engine", "GraphiteMergeTree"), // engine is a
property, not positional
new Transform[0], // partitions
Distributions.NONE, // distribution
new SortOrder[] { SortOrders.ascending(NamedReference.field("id")) },
// ORDER BY
new Index[0]);
// → UnsupportedOperationException: "ORDER BY clause is not supported for
engine: GraphiteMergeTree"
```
Note: the engine must be passed via `Map.of("engine", "GraphiteMergeTree")`
in the properties map. Passing empty properties defaults to `MergeTree` and the
bug does not manifest.
**Type conversion (load path):**
```sql
CREATE TABLE t_enum (id Int64, status Enum8('active'=1,'inactive'=2))
ENGINE=MergeTree ORDER BY id;
CREATE TABLE t_int128 (id Int64, big_val Int128) ENGINE=MergeTree ORDER BY
id;
CREATE TABLE t_bfloat (id Int64, score BFloat16) ENGINE=MergeTree ORDER BY
id;
```
Load each table via Gravitino REST API. Expected: `status` → enum type,
`big_val` → integer type, `score` → float type. Actual: all columns return
`ExternalType`.
### Additional context
- The type-switch fix is in `ClickHouseTypeConverter` — the same file and
the same `toGravitino` switch that #11884 extended for IPv4/IPv6, so it follows
established precedent
- The GraphiteMergeTree fix is a one-line change in
`ClickHouseTablePropertiesMetadata` (a separate file, not touched by #11884)
- Enum fix: add `if (typeName.startsWith("Enum"))` guard before the switch,
or strip parameters first
- Int128/Int256/UInt128/UInt256: add 4 switch cases (note: Gravitino
`DecimalType` caps precision at 38, so Int256/UInt256 cannot map to Decimal —
use `ExternalType` with correct `fromGravitino` restoration, or discuss with
community)
- BFloat16: add `case BFLOAT16: return Types.FloatType.get()`
--
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]