ClickHouse provides several string-based types optimized for different use cases.
Variable-length strings for general text data.
class User(BaseModel): name: str # String email: str # StringOptimized storage for strings with many repeated values. Use when you have fewer than ~10,000 unique values.
from typing import Annotated class Event(BaseModel): status: Annotated[str, "LowCardinality"] # LowCardinality(String) country: Annotated[str, "LowCardinality"] # LowCardinality(String)Use LowCardinality for columns like status codes, country codes, categories, or any string field with a limited set of repeated values. It significantly reduces storage and improves query performance.
Universally unique identifiers stored in native UUID format.
import { tags } from "typia"; interface User { id: string & tags.Format<"uuid">; // UUID}from uuid import UUID class User(BaseModel): id: UUID # UUID| ClickHouse Type | TypeScript | Python |
|---|---|---|
String | string | str |
LowCardinality(String) | string & LowCardinality | Annotated[str, "LowCardinality"] |
UUID | string & tags.Format<"uuid"> | UUID |