CQL data types

Built-in data types for columns.

CQL defines built-in data types for columns. The counter type is unique.

CQL Data Types
CQL Type Constants Description
ascii strings US-ASCII character string
bigint integers 64-bit signed long
blob blobs Arbitrary bytes (no validation), expressed as hexadecimal
boolean booleans true or false
counter integers Distributed counter value (64-bit long)
decimal integers, floats Variable-precision decimal

Java type

Note: When dealing with currency, it is a best practice to have a currency class that serializes to and from an int or use the Decimal form.
double integers, floats 64-bit IEEE-754 floating point

Java type

float integers, floats 32-bit IEEE-754 floating point

Java type

frozen tuples, collections, user-defined types A frozen value serializes multiple components into a single value. Non-frozen types allow updates to individual fields. Apache Cassandra™ treats the value of a frozen type as a blob. The entire value must be overwritten.
Note: Cassandra 2.1.0 to 2.1.2 requires using frozen for tuples:
frozen <tuple <int, tuple<text, double>>>
Cassandra 2.1.3+ does not require this keyword for tuples.
inet strings IP address string in IPv4 or IPv6 format, used by the python-cql driver and CQL native protocols
int integers 32-bit signed integer
list n/a A collection of one or more ordered elements
map n/a A JSON-style array of literals: { literal : literal, literal : literal ... }
set n/a A collection of one or more elements
text strings UTF-8 encoded string
timestamp integers, strings Date plus time, encoded as 8 bytes since epoch
timeuuid uuids Type 1 UUID only
tuple n/a Cassandra 2.1 and later. A group of 2-3 fields.
uuid uuids A UUID in standard UUID format
varchar strings UTF-8 encoded string
varint integers Arbitrary-precision integer

Java type

In addition to the CQL types listed in this table, you can use a string containing the name of a JAVA class (a sub-class of AbstractType loadable by Cassandra) as a CQL type. The class name should either be fully qualified or relative to the org.apache.cassandra.db.marshal package.

Enclose ASCII text, timestamp, and inet values in single quotation marks. Enclose names of a keyspace, table, or column in double quotation marks.

Java types 

The Java types, from which most CQL types are derived, are obvious to Java programmers. The derivation of the following types, however, might not be obvious:
Derivation of selective CQL types
CQL type Java type
decimal java.math.BigDecimal
float java.lang.Float
double java.lang.Double
varint java.math.BigInteger

CQL type compatibility 

CQL data types have strict requirements for conversion compatibility. The following table shows the allowed alterations for data types:
Datatype: May be altered to datatype
ascii, bigint, boolean, decimal, double, float, inet, int, timestamp, timeuuid, uuid, varchar, varint blob
int varint
text varchar
timeuuid uuid
varchar text
Clustering columns have even stricter requirements, because clustering columns mandate the order in which data is written to disk. The following table shows the allow alterations for data types used in clustering columns:
Data type may be altered to: Data type
int varint
text varchar
varchar text