Merge branch cassandra-3.11 into cassandra-4.0

This commit is contained in:
Benjamin Lerer 2022-09-28 14:43:48 +02:00
commit 46d5ef4148
1 changed files with 129 additions and 14 deletions

View File

@ -18,7 +18,7 @@
#
-->
h1. Cassandra Query Language (CQL) v3.4.3
h1. Cassandra Query Language (CQL) v3.4.5
@ -570,7 +570,7 @@ __Syntax:__
bc(syntax). <alter-materialized-view-stmt> ::= ALTER MATERIALIZED VIEW <viewname>
WITH <option> ( AND <option> )*
p.
p.
The @ALTER MATERIALIZED VIEW@ statement allows options to be update; these options are the same as <a href="#createTableOptions">@CREATE TABLE@'s options</a>.
@ -854,7 +854,7 @@ __Syntax:__
bc(syntax)..
<insertStatement> ::= INSERT INTO <tablename>
( ( <name-list> VALUES <value-list> )
| ( JSON <string> ))
| ( JSON <string> [ DEFAULT ( NULL | UNSET ) ]))
( IF NOT EXISTS )?
( USING <option> ( AND <option> )* )?
@ -952,7 +952,7 @@ h4(#updateOptions). @<options>@
The @UPDATE@ and @INSERT@ statements support the following options:
* @TIMESTAMP@: sets the timestamp for the operation. If not specified, the coordinator will use the current time (in microseconds) at the start of statement execution as the timestamp. This is usually a suitable default.
* @TTL@: specifies an optional Time To Live (in seconds) for the inserted values. If set, the inserted values are automatically removed from the database after the specified time. Note that the TTL concerns the inserted values, not the columns themselves. This means that any subsequent update of the column will also reset the TTL (to whatever TTL is specified in that update). By default, values never expire. A TTL of 0 is equivalent to no TTL. If the table has a default_time_to_live, a TTL of 0 will remove the TTL for the inserted or updated values.
* @TTL@: specifies an optional Time To Live (in seconds) for the inserted values. If set, the inserted values are automatically removed from the database after the specified time. Note that the TTL concerns the inserted values, not the columns themselves. This means that any subsequent update of the column will also reset the TTL (to whatever TTL is specified in that update). By default, values never expire. A TTL of 0 is equivalent to no TTL. If the table has a default_time_to_live, a TTL of 0 will remove the TTL for the inserted or updated values. A TTL of @null@ is equivalent to inserting with a TTL of 0.
h3(#deleteStmt). DELETE
@ -1649,7 +1649,7 @@ bc(syntax)..
| FUNCTION <functionname>
| ALL MBEANS
| ( MBEAN | MBEANS ) <objectName>
p.
p.
__Sample:__
@ -1679,7 +1679,7 @@ bc(syntax)..
| FUNCTION <functionname>
| ALL MBEANS
| ( MBEAN | MBEANS ) <objectName>
p.
p.
__Sample:__
@ -1718,6 +1718,7 @@ bc(syntax)..
| date
| decimal
| double
| duration
| float
| inet
| int
@ -1748,6 +1749,7 @@ p. The following table gives additional informations on the native data types, a
|@date@ | integers, strings |A date (with no corresponding time value). See "Working with dates":#usingdates below for more information.|
|@decimal@ | integers, floats |Variable-precision decimal|
|@double@ | integers |64-bit IEEE-754 floating point|
|@duration@ | duration |A duration with nanosecond precision. See "Working with durations":#usingdurations below for details.|
|@float@ | integers, floats |32-bit IEEE-754 floating point|
|@inet@ | strings |An IP address. It can be either 4 bytes long (IPv4) or 16 bytes long (IPv6). There is no @inet@ constant, IP address should be inputed as strings|
|@int@ | integers |32-bit signed int|
@ -1821,6 +1823,44 @@ They can also be input as string literals in any of the following formats:
* @08:12:54.123456@
* @08:12:54.123456789@
h3(#usingdurations). Working with durations
Values of the @duration@ type are encoded as 3 signed integers of variable lengths. The first integer represents the
number of months, the second the number of days and the third the number of nanoseconds. This is due to the fact that
the number of days in a month can change, and a day can have 23 or 25 hours depending on the daylight saving.
A duration can be input as:
* (quantity unit)+ like @12h30m@ where the unit can be:
** @y@: years (12 months)
** @mo@: months (1 month)
** @w@: weeks (7 days)
** @d@: days (1 day)
** @h@: hours (3,600,000,000,000 nanoseconds)
** @m@: minutes (60,000,000,000 nanoseconds)
** @s@: seconds (1,000,000,000 nanoseconds)
** @ms@: milliseconds (1,000,000 nanoseconds)
** @us@ or @µs@ : microseconds (1000 nanoseconds)
** @ns@: nanoseconds (1 nanosecond)
* ISO 8601 format: @P[n]Y[n]M[n]DT[n]H[n]M[n]S@ or @P[n]W@
* ISO 8601 alternative format: @P[YYYY]-[MM]-[DD]T[hh]:[mm]:[ss]@
For example:
bc(sample).
INSERT INTO RiderResults (rider, race, result) VALUES ('Christopher Froome', 'Tour de France', 89h4m48s);
INSERT INTO RiderResults (rider, race, result) VALUES ('BARDET Romain', 'Tour de France', PT89H8M53S);
INSERT INTO RiderResults (rider, race, result) VALUES ('QUINTANA Nairo', 'Tour de France', P0000-00-00T89:09:09);
h4. duration-limitation:
Duration columns cannot be used in a table's @PRIMARY KEY@. This limitation is due to the fact that
durations cannot be ordered. It is effectively not possible to know if @1mo@ is greater than @29d@ without a date
context.
A @1d@ duration is not equals to a @24h@ one as the duration type has been created to be able to support daylight
saving.
h3(#counters). Counters
@ -1944,6 +1984,47 @@ UPDATE plays SET scores = scores - [ 12, 21 ] WHERE id = '123-afde'; // removes
As with "maps":#map, TTLs if used only apply to the newly inserted/updated _values_.
h2(#arithmeticOperators). Arithmetic Operators
h3(#numberArithmetic). Number Arithmetic
CQL supports the following operators:
|_. Operator |_. Description |
| @-@ (unary) | Negates operand |
| @+@ | Addition |
| @-@ | Substraction |
| @*@ | Multiplication |
| @/@ | Division |
| @%@ | Returns the remainder of a division |
Arithmetic operations are only supported on numeric types or counters.
The return type of the operation will be based on the operand types:
|_. left/right |_. @tinyint@ |_. @smallint@ |_. @int@ |_. @bigint@ |_. @counter@ |_. @float@ |_. @double@ |_. @varint@ |_. @decimal@ |
| **@tinyint@** | @tinyint@ | @smallint@ | @int@ | @bigint@ | @bigint@ | @float@ | @double@ | @varint@ | @decimal@ |
| **@smallint@** | @smallint@ | @smallint@ | @int@ | @bigint@ | @bigint@ | @float@ | @double@ | @varint@ | @decimal@ |
| **@int@** | @int@ | @int@ | @int@ | @bigint@ | @bigint@ | @float@ | @double@ | @varint@ | @decimal@ |
| **@bigint@** | @bigint@ | @bigint@ | @bigint@ | @bigint@ | @bigint@ | @double@ | @double@ | @varint@ | @decimal@ |
| **@counter@** | @bigint@ | @bigint@ | @bigint@ | @bigint@ | @bigint@ | @double@ | @double@ | @varint@ | @decimal@ |
| **@float@** | @float@ | @float@ | @float@ | @double@ | @double@ | @float@ | @double@ | @decimal@ | @decimal@ |
| **@double@** | @double@ | @double@ | @double@ | @double@ | @double@ | @double@ | @double@ | @decimal@ | @decimal@ |
| **@varint@** | @varint@ | @varint@ | @varint@ | @decimal@ | @decimal@ | @decimal@ | @decimal@ | @decimal@ | @decimal@ |
| **@decimal@** | @decimal@ | @decimal@ | @decimal@ | @decimal@ | @decimal@ | @decimal@ | @decimal@ | @decimal@ | @decimal@ |
@*@, @/@ and @%@ operators have a higher precedence level than @+@ and @-@ operator. By consequence, they will be evaluated before. If two operator in an expression have the same precedence level, they will be evaluated left to right based on their position in the expression.
h3(#datetimeArithmetic). Datetime Arithmetic
A @duration@ can be added (+) or substracted (-) from a @timestamp@ or a @date@ to create a new @timestamp@ or @date@. So for instance:
bc(sample).
SELECT * FROM myTable WHERE t = '2017-01-01' - 2d
will select all the records with a value of @t@ which is in the last 2 days of 2016.
h2(#functions). Functions
@ -1956,18 +2037,18 @@ The @cast@ function can be used to converts one native datatype to another.
The following table describes the conversions supported by the @cast@ function. Cassandra will silently ignore any cast converting a datatype into its own datatype.
|_. from |_. to |
|@ascii@ |@text@, @varchar@ |
|@ascii@ |@text@, @varchar@ |
|@bigint@ |@tinyint@, @smallint@, @int@, @float@, @double@, @decimal@, @varint@, @text@, @varchar@ |
|@boolean@ |@text@, @varchar@ |
|@counter@ |@tinyint@, @smallint@, @int@, @bigint@, @float@, @double@, @decimal@, @varint@, @text@, @varchar@ |
|@date@ |@timestamp@ |
|@date@ |@timestamp@ |
|@decimal@ |@tinyint@, @smallint@, @int@, @bigint@, @float@, @double@, @varint@, @text@, @varchar@ |
|@double@ |@tinyint@, @smallint@, @int@, @bigint@, @float@, @decimal@, @varint@, @text@, @varchar@ |
|@float@ |@tinyint@, @smallint@, @int@, @bigint@, @double@, @decimal@, @varint@, @text@, @varchar@ |
|@inet@ |@text@, @varchar@ |
|@int@ |@tinyint@, @smallint@, @bigint@, @float@, @double@, @decimal@, @varint@, @text@, @varchar@ |
|@float@ |@tinyint@, @smallint@, @int@, @bigint@, @double@, @decimal@, @varint@, @text@, @varchar@ |
|@inet@ |@text@, @varchar@ |
|@int@ |@tinyint@, @smallint@, @bigint@, @float@, @double@, @decimal@, @varint@, @text@, @varchar@ |
|@smallint@ |@tinyint@, @int@, @bigint@, @float@, @double@, @decimal@, @varint@, @text@, @varchar@ |
|@time@ |@text@, @varchar@ |
|@time@ |@text@, @varchar@ |
|@timestamp@|@date@, @text@, @varchar@ |
|@timeuuid@ |@timestamp@, @date@, @text@, @varchar@ |
|@tinyint@ |@tinyint@, @smallint@, @int@, @bigint@, @float@, @double@, @decimal@, @varint@, @text@, @varchar@ |
@ -2015,6 +2096,8 @@ SELECT * FROM myTable WHERE t = now()
will never return any result by design, since the value returned by @now()@ is guaranteed to be unique.
@currentTimeUUID@ is an alias of @now@.
h4. @minTimeuuid@ and @maxTimeuuid@
@ -2029,7 +2112,25 @@ will select all rows where the @timeuuid@ column @t@ is strictly older than '201
_Warning_: We called the values generated by @minTimeuuid@ and @maxTimeuuid@ _fake_ UUID because they do no respect the Time-Based UUID generation process specified by the "RFC 4122":http://www.ietf.org/rfc/rfc4122.txt. In particular, the value returned by these 2 methods will not be unique. This means you should only use those methods for querying (as in the example above). Inserting the result of those methods is almost certainly _a bad idea_.
h3(#timeFun). Time conversion functions
h3(#datetimeFun). Datetime functions
h4(#curentDateTime). Retrieving the current date/time
The following functions can be used to retrieve the date/time at the time where the function is invoked:
|_. function name |_. output type |
| @currentTimestamp@ | @timestamp@ |
| @currentDate@ | @date@ |
| @currentTime@ | @time@ |
| @currentTimeUUID@ | @timeUUID@ |
For example the last 2 days of data can be retrieved using:
bc(sample).
SELECT * FROM myTable WHERE date >= currentDate() - 2d
h4(#timeFun). Time conversion functions
A number of functions are provided to "convert" a @timeuuid@, a @timestamp@ or a @date@ into another @native@ type.
@ -2249,7 +2350,7 @@ With @INSERT@ statements, the new @JSON@ keyword can be used to enable inserting
bc(sample).
INSERT INTO mytable JSON '{"\"myKey\"": 0, "value": 0}'
Any columns which are ommitted from the @JSON@ map will be defaulted to a @NULL@ value (which will result in a tombstone being created).
By default (or if @DEFAULT NULL@ is explicitly used), a column omitted from the @JSON@ map will be set to @NULL@, meaning that any pre-existing value for that column will be removed (resulting in a tombstone being created). Alternatively, if the @DEFAULT UNSET@ directive is used after the value, omitted column values will be left unset, meaning that pre-existing values for those column will be preserved.
h3(#jsonEncoding). JSON Encoding of Cassandra Data Types
@ -2450,9 +2551,23 @@ h2(#changes). Changes
The following describes the changes in each version of CQL.
h3. 3.4.5
* Adds support for arithmetic operators. See "Number Arithmetic":#numberArithmetic (see "CASSANDRA-11935":https://issues.apache.org/jira/browse/CASSANDRA-11935).
* Adds support for + and - operations on dates. See "Datetime Arithmetic":#datetimeArithmetic (see "CASSANDRA-11936":https://issues.apache.org/jira/browse/CASSANDRA-11936).
* Adds @currentTimestamp@, @currentDate@, @currentTime@ and @currentTimeUUID@ functions (see "CASSANDRA-13132":https://issues.apache.org/jira/browse/CASSANDRA-13132).
h3. 3.4.4
* @ALTER TABLE ALTER@ has been removed; a columns type may not be changed after creation (see "CASSANDRA-12443":https://issues.apache.org/jira/browse/CASSANDRA-12443).
* @ALTER TYPE ALTER@ has been removed; a fields type may not be changed after creation (see "CASSANDRA-12443":https://issues.apache.org/jira/browse/CASSANDRA-12443).
h3. 3.4.3
* Adds a new @duration@ data type See "Data Types":#types (see "CASSANDRA-11873":https://issues.apache.org/jira/browse/CASSANDRA-11873).
* Support for @GROUP BY@. See "@<group-by>@":#selectGroupBy (see "CASSANDRA-10707":https://issues.apache.org/jira/browse/CASSANDRA-10707).
* Adds a @DEFAULT UNSET@ option for @INSERT JSON@ to ignore omitted columns (see "CASSANDRA-11424":https://issues.apache.org/jira/browse/CASSANDRA-11424).
* Allows @null@ as a legal value for TTL on insert and update. It will be treated as equivalent to inserting a 0 (see "CASSANDRA-12216":https://issues.apache.org/jira/browse/CASSANDRA-12216).
h3. 3.4.2