Overview
YCQL supports a comprehensive set of data types compatible with Apache Cassandra CQL, including primitive types, collection types, and special types for distributed systems.Primitive Types
Numeric Types
TINYINT
8-bit signed integer.- Range: -128 to 127
- Storage: 1 byte
- Example:
SMALLINT
16-bit signed integer.- Range: -32,768 to 32,767
- Storage: 2 bytes
- Example:
INT / INTEGER
32-bit signed integer.- Range: -2,147,483,648 to 2,147,483,647
- Storage: 4 bytes
- Example:
BIGINT
64-bit signed integer.- Range: -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
- Storage: 8 bytes
- Example:
VARINT
Arbitrary-precision integer.- Range: Unlimited
- Storage: Variable (depends on value)
- Example:
DECIMAL
Arbitrary-precision decimal number.- Format: Can include exponential notation (e.g.,
1.23E+10) - Storage: Variable
- Example:
FLOAT
32-bit IEEE 754 floating point.- Precision: ~7 decimal digits
- Storage: 4 bytes
- Example:
DOUBLE
64-bit IEEE 754 floating point.- Precision: ~15 decimal digits
- Storage: 8 bytes
- Example:
String Types
VARCHAR / TEXT
UTF-8 encoded string.- Size: Variable length
- Max Size: 64MB (practical limit)
- Example:
Boolean Type
BOOLEAN
True or false value.- Values:
trueorfalse - Storage: 1 byte
- Example:
Binary Type
BLOB
Binary large object.- Format: Hexadecimal notation (
0xprefix) - Size: Variable
- Example:
Date and Time Types
TIMESTAMP
Date and time with millisecond or microsecond precision.- Format: Date string or milliseconds since epoch
- Precision: Milliseconds (default) or microseconds (with flag)
- Storage: 8 bytes
- Example:
Z- UTC+/-HH:MM- Offset (e.g.,+05:30,-08:00)UTCorGMT- Named timezoneAmerica/New_York- IANA timezone database names
DATE
Date without time component.- Format:
YYYY-MM-DD - Range: 1900-01-01 to 9999-12-31
- Example:
TIME
Time of day (without date).- Format:
HH:MM:SS[.fff] - Precision: Nanosecond
- Example:
UUID Types
UUID
Universally unique identifier (128-bit).- Format:
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx - Storage: 16 bytes
- Example:
TIMEUUID
Time-based UUID (version 1).- Format: Same as UUID but with embedded timestamp
- Ordering: Chronologically sortable
- Example:
Network Type
INET
IPv4 or IPv6 address.- Format: Standard IP notation
- Example:
JSON Type
JSONB
Binary JSON storage (YugabyteDB-specific).- Format: JSON object or array
- Indexing: Supports GIN indexes on JSONB columns
- Example:
Collection Types
MAP
Key-value pairs.- Syntax:
MAP<key_type, value_type> - Limitations: No nested collections; null values not allowed
- Example:
SET
Unique, unordered elements.- Syntax:
SET<element_type> - Characteristics: Automatically removes duplicates
- Example:
LIST
Ordered, potentially duplicate elements.- Syntax:
LIST<element_type> - Characteristics: Preserves insertion order and duplicates
- Example:
Collection Limitations
- No nested collections:
MAP<TEXT, LIST<INT>>is not supported - No null values: Collections cannot contain null elements
- Cannot be primary keys: Collections cannot be part of primary key
- Size limits: Keep collection sizes reasonable for performance
Special Types
COUNTER
Atomic 64-bit integer counter.- Operations: Only increment and decrement
- Constraints: Cannot be part of primary key; requires dedicated counter table
- Example:
Type Conversion Functions
YCQL provides functions to convert between types and blobs:To Blob
From Blob
Data Type Compatibility
Implicit Conversions
YCQL supports automatic type promotion in some cases:INT→BIGINT→DECIMALFLOAT→DOUBLETINYINT→SMALLINT→INT→BIGINT
Ordering and Comparison
- Numeric types: Natural ordering
- Text types: Lexicographic (UTF-8) ordering
- BLOB: Byte-wise comparison
- TIMESTAMP: Chronological ordering
- TIMEUUID: Time-based ordering
- Collections: Not comparable (cannot use in WHERE clauses)
Best Practices
- Choose appropriate numeric types: Use smallest type that fits your data range
- Use TIMEUUID for time-series: Provides both uniqueness and time ordering
- Limit collection sizes: Large collections impact performance
- Consider JSONB for flexible schemas: Better than wide tables with many nullable columns
- Use DECIMAL for financial data: Avoid floating-point precision issues
- Leverage COUNTER for statistics: Efficient atomic increments

