Lindorm CQL is a typed language that supports a set of data types. This topic describes the data types that are supported by Lindorm CQL.
Basic data types
Data type | Supported constant | Description |
---|---|---|
bigint | integer | The 64-bit signed long value. |
blob | blob | A number of bytes. The length of these bytes ranges from 0 to infinity. |
boolean | boolean | Valid values: true and false. |
counter | integer | The counter column that contains 64-bit signed values. |
date | integer, string | The date. |
decimal | integer, float | The variable-granularity decimal value. |
double | integer, float | The 64-bit IEEE-754 floating value. |
float | integer, float | The 32-bit IEEE-754 floating value. |
inet | string | The IP address. Valid types: IPv4 and IPv6. All inputs are stored as strings because no IP data type exists. |
int | integer | 32-bit signed int |
smallint | integer | 16-bit signed int |
text | string | The string in the UTF-8 format. |
time | integer, string | The time that is measured in nanoseconds. |
timestamp | integer, string | The timestamp that is measured in microseconds. |
timeuuid | uuid | The Version 1 UUID. In most cases, the UUID is used as a conflict-free timestamp. |
tinyint | integer | 8-bit signed int |
uuid | uuid | The UUID. |
varint | integer | The integer of a variable granularity. |
nested | string | The JSON string that can be nested. |
Counter
The counter type that is used to specify a counter column. The counter type of Lindorm
CQL is slightly different from the counter type of Cassandra. The counter tables of
Cassandra contain only counter columns. However, the counter tables of Lindorm CQL
can contain counter columns and non-counter columns. Example:
CREATE TABLE persioninfo (name text primary key, age counter, address text);
UPDATE persioninfo SET age = age + 2 WHERE name = 'my';
INSERT INTO persioninfo (name, age, address) VALUES ( 'my', 30, 'hz');
Timestamp
You can specify an integer or string to represent a point in time. The following example
is used to represent the 04:05:00 March 2, 2011 GMT point in time.
CREATE TABLE persioninfo ( name text PRIMARY KEY , birthtime timestamp , address text );
INSERT INTO persioninfo (name, birthtime, address) VALUES ( 'my', 1299038700000, 'hz');
INSERT INTO persioninfo (name, birthtime, address) VALUES ( 'mm', '2011-03-02 04:05+0000', 'hz');
INSERT INTO persioninfo (name, birthtime, address) VALUES ( 'lucy', '2011-03-02 04:05:00+0000', 'bj');
Time
You can use an integer or string to represent a time. If a string is used to represent
a time, the string must be specified in the
hh:mm:ss[.fffffffff]
format. The [.fffffffff]
parameter is optional. Example:CREATE TABLE persioninfo ( name text PRIMARY KEY , birthtime time , adress text );
INSERT INTO persioninfo (name,birthtime,adress) VALUES ( 'lili', '08:12:54', 'hz');
date
You can use an integer or string to represent a date. If a string is used to represent
a time, the string must be specified in the
yyyy-mm-dd
format. Example: CREATE TABLE persioninfo ( name text PRIMARY KEY , birthday date , address text );
INSERT INTO persioninfo (name,birthday,address) VALUES ( 'lucy', '2021-02-01', 'beijing');
nested
The nested type. When you create a table, you can set the data type of a column to
nested. You can write JSON data as strings to the column. You can use a SELECT statement
in which the
search_query
clause is specified to run a nested sub-query on the column. To implement this sub-query,
the search index
feature of Lindorm must be used in combination with the preceding setting. Note:
If you execute a DESCRIBE
statement on the table that contains the column, the statement still returns the
text data for the column. In addition, nested data is still displayed as text data
on the open source driver side. Example: CREATE TABLE persioninfo ( name text PRIMARY KEY , info nested , address text );
CREATE SEARCH INDEX sidx ON ctable3 WITH COLUMNS (info ,address );
INSERT INTO ctable3 (name,info,address) VALUES ( 'lilei', '{"school":"alibaba"}', 'hz');
SELECT * FROM ctable3 WHERE search_query = '{+address:hz}';
Unsupported data types
- Collection data types: SET, LIST, and MAP.
- User-defined types.
- Basic data types: Duration.