You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by GitBox <gi...@apache.org> on 2020/10/02 13:01:46 UTC

[GitHub] [cassandra] blerer commented on a change in pull request #745: [CASSANDRA-16117] Improve docs about frozen types and invert UDT/Tuple order

blerer commented on a change in pull request #745:
URL: https://github.com/apache/cassandra/pull/745#discussion_r498806262



##########
File path: doc/source/cql/types.rst
##########
@@ -400,20 +398,46 @@ Further, lists support:
 
 Lastly, as for :ref:`maps <maps>`, TTLs when used only apply to the newly inserted values.
 
+.. _tuples:
+
+Tuples
+^^^^^^
+
+CQL also support tuples and tuple types (where the elements can be of different types). Tuple types and tuple literals
+are defined by:
+
+.. productionlist::
+   tuple_type: TUPLE '<' `cql_type` ( ',' `cql_type` )* '>'
+   tuple_literal: '(' `term` ( ',' `term` )* ')'
+
+and can be used thusly::
+
+    CREATE TABLE durations (
+        event text,
+        duration tuple<int, text>,
+    )
+
+    INSERT INTO durations (event, duration) VALUES ('ev1', (3, 'hours'));
+
+Unlike other "composed" types (collections and UDT), a tuple is always :ref:`frozen <frozen>` (without the need of the
+`frozen` keyword). It is not possible to update only some elements of a tuple (without updating the whole tuple).
+A tuple literal must have the same number of items as its declaring type (some of
+those values can be null but they must be explicitly declared).
+
 .. _udts:
 
 User-Defined Types
 ^^^^^^^^^^^^^^^^^^
 
-CQL support the definition of user-defined types (UDT for short). Such a type can be created, modified and removed using
-the :token:`create_type_statement`, :token:`alter_type_statement` and :token:`drop_type_statement` described below. But
+CQL support the definition of user-defined types (UDT for short), which is basically a tuple on steroids - it's
+literally an extension of the class that represents a tuple. Such a type can be created, modified and removed using the
+:token:`create_type_statement`, :token:`alter_type_statement` and :token:`drop_type_statement` described below. But

Review comment:
       You are right, no need to add anything. Sorry for missing that.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org