You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ClickHouse uses `Nullable(type)` wrapping for nullable columns, `Enum8(...)` for enums, `Tuple(Float64, Float64)` for points, and `TYPE minmax GRANULARITY 3` for indexes. Foreign keys, stored procedures, triggers, generated columns, and CHECK constraints throw `UnsupportedException`.
2035
2035
2036
-
Supports the `TableComments`, `ColumnComments`, and `DropPartition` interfaces.
2036
+
Supports the `TableComments`, `ColumnComments`, `DropPartition`, `Views`, and `Databases` interfaces.
2037
2037
2038
2038
**Engine selection** — choose from 10 variants of the `Engine` enum:
2039
2039
@@ -2130,6 +2130,73 @@ $schema->table('events')
2130
2130
2131
2131
Setting names must match `[A-Za-z_][A-Za-z0-9_]*`; string values are restricted to `[A-Za-z0-9_.\-+/]*`. Use ints / floats / booleans for everything else. Other dialects ignore the call.
2132
2132
2133
+
**LowCardinality** — wrap a column type in `LowCardinality(...)` for compact dictionary-encoded storage on string columns with a small number of distinct values (status enums, type discriminators, country codes, category labels):
// `country` Nullable(LowCardinality(String))) ENGINE = MergeTree() ORDER BY (`id`)
2144
+
```
2145
+
2146
+
`Nullable` is applied outside `LowCardinality` to match ClickHouse's required wrapping order. The `lowCardinality()` method is only available on the ClickHouse builder — callers on other dialects (`MySQL`, `PostgreSQL`, `SQLite`, `MongoDB`) cannot reach this method at all.
2147
+
2148
+
**FixedString(N)** — fixed-length string column. Use for ISO codes, hash digests, and other values whose byte length is known and constant:
2149
+
2150
+
```php
2151
+
$schema->table('locations')
2152
+
->bigInteger('id')->primary()
2153
+
->fixedString('country_code', 2) // ISO 3166-1 alpha-2
->string('payload')->codec('ZSTD(3)') // text column
2173
+
->create();
2174
+
2175
+
// CREATE TABLE `metrics` (`id` Int64,
2176
+
// `ts` DateTime64(3) CODEC(Delta(4), LZ4),
2177
+
// `value` Int64 CODEC(T64, LZ4),
2178
+
// `payload` String CODEC(ZSTD(3))) ENGINE = MergeTree() ORDER BY (`id`)
2179
+
```
2180
+
2181
+
Each codec string is emitted verbatim; supply codec arguments inline (`'Delta(4)'`, `'ZSTD(3)'`). Codec strings must not be empty or contain a semicolon. The `codec()` method is only available on the ClickHouse builder.
2182
+
2183
+
**SAMPLE BY** — declare a sampling expression for approximate-query support (`SELECT ... SAMPLE k`). Emitted after `ORDER BY` and before `TTL` / `SETTINGS`:
The expression is emitted verbatim and must not be empty or contain a semicolon. `SAMPLE BY` only applies to engines that take an `ORDER BY` clause (the MergeTree family); using it with `Memory`, `Log`, `TinyLog`, or `StripeLog` throws `UnsupportedException`. The `sampleBy()` method is only available on the ClickHouse builder.
2197
+
2198
+
These OLAP-shaped modifiers live on the ClickHouse-specific `Column\ClickHouse` and `Table\ClickHouse` builders. Because the methods only exist on the dialect's own builder subclasses, calling `->lowCardinality()` or `->sampleBy()` on a `MySQL`, `PostgreSQL`, `SQLite`, or `MongoDB` builder fails at the type level, with no runtime branch needed.
0 commit comments