Data Types
Moose supports a comprehensive set of ClickHouse column types across both TypeScript and Python. This section covers all supported types, their syntax, and how they map to ClickHouse.
Type Categories
Basic Types
- Strings —
String,LowCardinality(String),UUID - Integers —
Int8toInt64,UInt8toUInt64 - Floats —
Float32,Float64 - Decimals — Fixed-point
Decimal(P,S) - Booleans —
Boolean - Date & Time —
Date,DateTime,DateTime64 - Network —
IPv4,IPv6
Complex Types
- Arrays —
Array(T) - Maps —
Map(K, V) - Nested — Embedded objects
- Tuples — Named tuples
- Enums — Enumerated values
- Geometry —
Point,Ring,Polygon, etc.
Special Types
- JSON — Dynamic and typed JSON columns
- Nullable — Optional fields
- Aggregates —
SimpleAggregateFunctionfor pre-aggregation
Schema Features
- Column Comments — Add descriptions to columns that appear in ClickHouse DDL
Quick Reference
| Category | TypeScript | Python |
|---|---|---|
| String | string | str |
| Integer | Int32, UInt64, etc. | Annotated[int, "int32"] |
| Float | Float32, Float64, number | float |
| Boolean | boolean | bool |
| Date | Date, DateTime | date, datetime |
| Array | T[] | List[T] |
| Map | Record<K, V> | Dict[K, V] |
| Optional | field?: T | Optional[T] |
Best Practices
- Use specific integer types when you know the value ranges to save storage
- Prefer
Float64for most floating-point calculations unless storage is critical - Use
LowCardinalityfor string columns with repeated values (< 10,000 unique) - Choose appropriate DateTime precision based on your accuracy needs
- Order columns by cardinality (low to high) for better compression
- Add column comments to document field purposes in your schema