Cassandra Data Types

Cassandra Data Types Definition

Apache Cassandra supports the Cassandra Query Language, or CQL. Apache Cassandra Data Types are the classifications of data that indicate what type of data can be stored in a variable or object. When the programmer specifies a data type, they tell the compiler how to interpret, store, and use the data.

Diagram depicting cassandra data types which include custom types, native types, collection types, tuple types and user-defined types.

Cassandra Data Types FAQs

What Are Different Data Types In Cassandra?

Cassandra Query Language (CQL) is a strongly typed language; variables are assigned a specific type, rather than relying on a compiler to infer the intended operation from the value. Built-in Cassandra Data Types include numeric types, collection types, string types, and binary large objects (BLOBs) for byte-array data. CQL also supports custom data types.

What Are Cassandra Supported Data Types?

Cassandra Data Types are classified into native types, collection types, tuple types, user-defined types, and custom types.

Native Types:

  • ascii – strings
  • bigint – 64-bit signed long integer
  • blob – arbitrary bytes
  • boolean – true or false
  • counter – 64-bit signed integer for increment and decrement options. Don’t use a counter type for a sequential-numbered key column. A timeuuid type would be a better choice.
  • date – date without a time component
  • decimal – variable-precision decimal number
  • double – 64-bit floating point number
  • duration – represents an amount of time with nanosecond precision
  • float – 32-bit floating point number
  • inet – an IPv4 or IPv6 string
  • int – 32-bit signed integer 
  • smallint – 16-bit signed integer
  • text – UTF-8 encoded string
  • time – time without a date component, with nanosecond precision
  • timestamp – date and time with millisecond precision
  • timeuuid – unique timestamp (conflict-free version 1 UUID)
  • tinyint – 8-bit signed integer
  • uuid – universally unique identifier (any version)
  • varchar – UTF-8 encoded string
  • varint – arbitrary-precision integer

CQL Collection Types include maps, sets, and lists:

  • Cassandra Map Data Type – A sorted set of key-value pairs with unique keys, sorted by the key
  • Cassandra Set Data Type – A sorted collection of unique values
  • Cassandra List Data Type – A collection of non-unique values, ordered by their position in the list. Sets are generally more efficient than Lists if the values can be unique. 

Cassandra Tuple Data Types provide a way to store a fixed number of related data elements, similar to a key-value pair, but with more than two elements allowed. A tuple can take the place of a User-Defined-Type (UDT), but a UDT is more descriptive, especially if there are many data elements.

Cassandra CQL User-Defined-Types (UDTs) are complex types that look a lot like objects in other programming languages with multiple named properties, with types specified.

Cassandra Custom Data Types are types implemented in Java, instead of as a CQL expression.

How To Create Custom Cassandra Data Types?

Cassandra Data Types include the most common types a programmer would need. They also support CQL custom data types that can be implemented in Java by extending the org.apache.cassandra.db.marshal.AbstractType class.

What Type of Data Model Does Cassandra Use?

Cassandra column families contain an ordered collection of rows. Each row contains a collection of columns. A table contains columns, but some rows will have different columns than others. A column is the basic Cassandra data structure with three values–a name, value, and timestamp.

What Cassandra Column Data Types Are Supported in a Column Family?

Cassandra columns can use almost any of the data types, but there are restrictions on the Counter type, which cannot be used as a key in a column family. 

What Is a Frozen Cassandra List Data Type?

A Cassandra List Data Type can be marked as frozen. If a List is not frozen, elements in the list can be updated individually. If it is frozen, the entire list will be overwritten when it is updated. A List cannot contain another List unless the inner List is frozen. The frozen type will be treated as a blob.

Does ScyllaDB Support Cassandra Data Types?

ScyllaDB fully supports the Cassandra Query Language, including all Cassandra Data Types. ScyllaDB provides full Cassandra compatibility while delivering better performance, consistent low latency, and highly efficient hardware utilization.

Trending NoSQL Resources

ScyllaDB University Mascot

ScyllaDB University

Get started on your path to becoming a ScyllaDB expert.