Core types

Discover the core types available in CQL.

Core types are data types that have a literal syntax for representing values, meaning that you can write a literal value of that type directly into your query.

Examples of core types include the number type, which represents all numbers, and the string type, which represents all possible combinations of characters.

This summary provides an overview of the core types:

TypeDescription
NullThe absence of a value.
BooleanA binary value, such as true/false or yes/no.
NumberA numeric value, including integers and real numbers.
OrdinalA natural number that represents a position in a sequence.
IntegerA whole number, either positive or negative.
DecimalA precise real number.
FloatAn approximate real number.
StringA sequence of characters used to represent text.
RegexA pattern for matching text.
CollectionA group of related elements, including lists, sets, and maps.
ComparableA value that has a concept of order.
PrimitiveThe most basic types in CQL.

Null

The null type represents the possible absence of a value. It has a single value, represented by the literal null.

Learn more on how to represent null values in null literals.

Boolean

The boolean type represents binary values, such as true/false or yes/no. It has two possible values, represented by the literals true and false.

Learn more on how to represent boolean values in boolean literals.

Number

Number is the supertype of all numeric types, including integers and real numbers such as decimals and floats. More details about subtypes are described in the following sections.

Learn more on how to represent numeric values in number literals.

Ordinal

An ordinal is a natural number representing a position in a sequence, such as 1st, 2nd, 3rd, and so on.

The underlying type is a 64-bit integer. However, because ordinals are unsigned, the range is limited to 1 through 9223372036854775807.

Learn more on how to represent ordinals in ordinal literals.

Integer

An integer represents a whole number, either positive or negative.

The underlying type is a 64-bit signed integer, meaning that values can range from -9223372036854775808 to 9223372036854775807.

Learn more on how to represent integers in integer literals.

Decimal

A decimal refers to precise real numbers that include a fractional part.

Unlike integers, decimals do not have maximum or minimum values but do have a maximum precision of 28 significant digits.

Learn more on how to represent decimals in decimal literals.

Float

Floats represent approximated real numbers and are commonly used for continuous values that do not require precision.

The underlying float type is a 64-bit floating-point number. It can accurately represent integers within the range of -9007199254740991 to 9007199254740991 and a subset of decimal numbers.

Learn more on how to represent floats in float literals.

String

Strings are sequences of characters used to represent text. They can include letters, numbers, punctuation marks, special symbols like emoji, and Unicode characters.

Learn more on how to represent strings in string literals.

Regex

Regex, short for regular expressions, represents patterns for matching strings of text.

Regular expressions have different variants, each with its own syntax and features. The regex type in CQL is powered by the PCRE variant, which is widely used and known for its rich feature set and strong performance.

Learn more on how to represent regular expressions in regex literals.

Collection

Collection is an abstract data type that represents a group of related elements.

Although the collection type is often associated with lists, sets, and maps, it can refer to any group of items. For example, the results of a range operation and a wildcard selector are both collections.

Learn more on how to represent collections in collection literals.

List

A list is an ordered collection of elements, where each element has an index representing its position. It allows duplicates, meaning the same element can appear multiple times in the list.

See the section on lists for more details on how to represent lists.

Set

The concept of sets refers to collections of unique items, which means that any collection can be considered a set — as long as it does not contain duplicates. So whenever you see the term set, you can assume that it refers to a collection where the items are unique.

See the section on sets for more details on how to represent sets.

Map

A map is a collection of key-value pairs where each key is unique and associated with a value. Maps are also sometimes called dictionaries or associative arrays.

See the section on maps for more details on how to represent maps.

Comparable

Comparable is an abstract type that represents all values that have a concept of order, including numbers, strings, dates, and times.

A value is comparable if it can be sorted in a particular order relative to other values of the same type. For example, you can compare two numbers to see which is greater, or two strings to determine which comes first alphabetically.

For more details on what is comparable, see the section on comparability.

Primitive

Primitive is an abstract type that represents the most basic types in CQL, which includes null, boolean, number, and string.

Learn more on how to represent primitives in literal expressions.