Skip to content

Commit

Permalink
Improve type mapping documentation for Cassandra connector
Browse files Browse the repository at this point in the history
  • Loading branch information
Terry Blessing authored and ebyhr committed Sep 5, 2022
1 parent bb608ef commit 692a5c3
Showing 1 changed file with 151 additions and 37 deletions.
188 changes: 151 additions & 37 deletions docs/src/main/sphinx/connector/cassandra.rst
Original file line number Diff line number Diff line change
Expand Up @@ -198,43 +198,157 @@ This table can then be queried in Trino::

SELECT * FROM cassandra.mykeyspace.users;

Data types
----------

The data types mappings are as follows:

================ ======
Cassandra Trino
================ ======
ASCII VARCHAR
BIGINT BIGINT
BLOB VARBINARY
BOOLEAN BOOLEAN
DATE DATE
DECIMAL DOUBLE
DOUBLE DOUBLE
FLOAT REAL
INET IPADDRESS
INT INTEGER
LIST<?> VARCHAR
MAP<?, ?> VARCHAR
SET<?> VARCHAR
SMALLINT SMALLINT
TEXT VARCHAR
TIMESTAMP TIMESTAMP(3) WITH TIME ZONE
TIMEUUID UUID
TINYINT TINYINT
TUPLE ROW with anonymous fields
UUID UUID
UDT ROW with field names
VARCHAR VARCHAR
VARINT VARCHAR
================ ======

Any collection (LIST/MAP/SET) can be designated as FROZEN, and the value is
mapped to VARCHAR. Additionally, blobs have the limitation that they cannot be empty.

Types not mentioned in the table above are not supported.
.. _cassandra-type-mapping:

Type mapping
------------

Because Trino and Cassandra each support types that the other does not, this
connector modifies some types when reading or writing data. Data types may not
map the same way in both directions between Trino and the data source. Refer to
the following sections for type mapping in each direction.

Cassandra type to Trino type mapping
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The connector maps Cassandra types to the corresponding Trino types according to
the following table:

.. list-table:: Cassandra type to Trino type mapping
:widths: 30, 25, 50
:header-rows: 1

* - Cassandra type
- Trino type
- Notes
* - ``BOOLEAN``
- ``BOOLEAN``
-
* - ``TINYINT``
- ``TINYINT``
-
* - ``SMALLINT``
- ``SMALLINT``
-
* - ``INT``
- ``INTEGER``
-
* - ``BIGINT``
- ``BIGINT``
-
* - ``FLOAT``
- ``REAL``
-
* - ``DOUBLE``
- ``DOUBLE``
-
* - ``DECIMAL``
- ``DOUBLE``
-
* - ``ASCII``
- ``VARCHAR``
- US-ASCII character string
* - ``TEXT``
- ``VARCHAR``
- UTF-8 encoded string
* - ``VARCHAR``
- ``VARCHAR``
- UTF-8 encoded string
* - ``VARINT``
- ``VARCHAR``
- Arbitrary-precision integer
* - ``BLOB``
- ``VARBINARY``
-
* - ``DATE``
- ``DATE``
-
* - ``TIMESTAMP``
- ``TIMESTAMP(3) WITH TIME ZONE``
-
* - ``LIST<?>``
- ``VARCHAR``
-
* - ``MAP<?, ?>``
- ``VARCHAR``
-
* - ``SET<?>``
- ``VARCHAR``
-
* - ``TUPLE``
- ``ROW`` with anonymous fields
-
* - ``UDT``
- ``ROW`` with field names
-
* - ``INET``
- ``IPADDRESS``
-
* - ``UUID``
- ``UUID``
-
* - ``TIMEUUID``
- ``UUID``
-

No other types are supported.

Trino type to Cassandra type mapping
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The connector maps Trino types to the corresponding Cassandra types according to
the following table:

.. list-table:: Trino type to Cassandra type mapping
:widths: 30, 25, 50
:header-rows: 1

* - Trino type
- Cassandra type
- Notes

* - ``BOOLEAN``
- ``BOOLEAN``
-
* - ``TINYINT``
- ``TINYINT``
-
* - ``SMALLINT``
- ``SMALLINT``
-
* - ``INTEGER``
- ``INT``
-
* - ``BIGINT``
- ``BIGINT``
-
* - ``REAL``
- ``FLOAT``
-
* - ``DOUBLE``
- ``DOUBLE``
-
* - ``VARCHAR``
- ``TEXT``
-
* - ``DATE``
- ``DATE``
-
* - ``TIMESTAMP(3) WITH TIME ZONE``
- ``TIMESTAMP``
-
* - ``IPADDRESS``
- ``INET``
-
* - ``UUID``
- ``UUID``
-


No other types are supported.

Partition key types
-------------------

Partition keys can only be of the following types:

Expand Down

0 comments on commit 692a5c3

Please sign in to comment.