Cassandra Query Language (CQL) Elements in Amazon Keyspaces - Amazon Keyspaces (for Apache Cassandra)

Cassandra Query Language (CQL) Elements in Amazon Keyspaces

Learn about the Cassandra Query Language (CQL) elements that are supported by Amazon Keyspaces, including identifiers, constants, terms, and data types.


Identifiers (or names) are used to identify tables, columns, and other objects. An identifier can be quoted or not quoted. The following applies.

identifier ::= unquoted_identifier | quoted_identifier unquoted_identifier ::= re('[a-zA-Z][a-zA-Z0-9_]*') quoted_identifier ::= '"' (any character where " can appear if doubled)+ '"'


The following constants are defined.

constant ::= string | integer | float | boolean | uuid | blob | NULL string ::= '\'' (any character where ' can appear if doubled)+ '\'' '$$' (any character other than '$$') '$$' integer ::= re('-?[0-9]+') float ::= re('-?[0-9]+(\.[0-9]*)?([eE][+-]?[0-9+])?') | NAN | INFINITY boolean ::= TRUE | FALSE uuid ::= hex{8}-hex{4}-hex{4}-hex{4}-hex{12} hex ::= re("[0-9a-fA-F]") blob ::= '0' ('x' | 'X') hex+


A term denotes the kind of values that are supported. Terms are defined by the following.

term ::= constant | literal | function_call | arithmetic_operation | type_hint | bind_marker literal ::= collection_literal | udt_literal | tuple_literal function_call ::= identifier '(' [ term (',' term)* ] ')' arithmetic_operation ::= '-' term | term ('+' | '-' | '*' | '/' | '%') term

Data Types

Amazon Keyspaces supports the following data types:

String Types

Data Type Description


Represents an ASCII character string.


Represents a UTF-8 encoded string.


Represents a UTF-8 encoded string (varchar is an alias for text).

Numeric Types

Data Type Description


Represents a 64-bit signed long.


Represents a 64-bit signed integer counter. For more information, see Counters.


Represents a variable-precision decimal.


Represents a 64-bit IEEE 754 floating point.


Represents a 32-bit IEEE 754 floating point.


Represents a 32-bit signed int.


Represents an integer of arbitrary precision.


A counter column contains a 64-bit signed integer. The counter value is incremented or decremented using the UPDATE statement, and it cannot be set directly. This makes counter columns useful for tracking counts. For example, you can use counters to track the number of entries in a log file or the number of times a post has been viewed on a social network. The following restrictions apply to counter columns:

  • A column of type counter cannot be part of the primary key of a table.

  • In a table that contains one or more columns of type counter, all columns in that table must be of type counter.

In cases where a counter update fails, for example, due to timeouts or loss of connection with Amazon Keyspaces, the client doesn't know whether the counter value was updated. If the update is retried, the update to the counter value might get applied a second time.

Blob Type

Data Type Description


Represents arbitrary bytes.

Boolean Type

Data Type Description


Represents true or false.

Time-Related Types

Data Type Description


Represents a timestamp.


Represents a version 1 UUID.

Collection Types

Data Type Description


Represents an ordered collection of literal elements.


Represents an unordered collection of key-value pairs.


Represents an unordered collection of one or more literal elements.


Represents a bounded group of literal elements.

Other Types

Data Type Description


A string representing an IP address, in either IPv4 or IPv6 format.