Merge branch 'cassandra-5.0' into trunk

This commit is contained in:
Andrés de la Peña 2023-10-25 12:15:26 +01:00
commit e8c5fe31a2
5 changed files with 73 additions and 26 deletions

View File

@ -3,6 +3,7 @@
* Add the ability to disable bulk loading of SSTables (CASSANDRA-18781)
* Clean up obsolete functions and simplify cql_version handling in cqlsh (CASSANDRA-18787)
Merged from 5.0:
* Add cqlsh autocompletion for the vector data type (CASSANDRA-18946)
* Fix nodetool tablehistograms output to avoid printing repeated information and ensure at most two arguments (CASSANDRA-18955)
* Change the checksum algorithm SAI-related files use from CRC32 to CRC32C (CASSANDRA-18836)
* Correctly remove Index.Group from IndexRegistry (CASSANDRA-18905)

View File

@ -21,7 +21,7 @@ from cqlshlib.cqlhandling import CqlParsingRuleSet, Hint
simple_cql_types = {'ascii', 'bigint', 'blob', 'boolean', 'counter', 'date', 'decimal', 'double', 'duration', 'float',
'inet', 'int', 'smallint', 'text', 'time', 'timestamp', 'timeuuid', 'tinyint', 'uuid', 'varchar',
'varint'}
simple_cql_types.difference_update(('set', 'map', 'list'))
simple_cql_types.difference_update(('set', 'map', 'list', 'vector'))
class UnexpectedTableStructure(UserWarning):
@ -303,7 +303,7 @@ JUNK ::= /([ \t\r\f\v]+|(--|[/][/])[^\n\r]*([\n\r]|$)|[/][*].*?[*][/])/ ;
<userType> ::= utname=<cfOrKsName> ;
<storageType> ::= ( <simpleStorageType> | <collectionType> | <frozenCollectionType> | <userType> ) ( <column_mask> )? ;
<storageType> ::= ( <simpleStorageType> | <collectionType> | <frozenCollectionType> | <vectorType> | <userType> ) ( <column_mask> )? ;
<column_mask> ::= "MASKED" "WITH" ( "DEFAULT" | <functionName> <selectionFunctionArguments> );
@ -319,6 +319,8 @@ JUNK ::= /([ \t\r\f\v]+|(--|[/][/])[^\n\r]*([\n\r]|$)|[/][*].*?[*][/])/ ;
| "frozen" "<" "set" "<" <storageType> ">" ">"
;
<vectorType> ::= "vector" "<" <storageType> "," <wholenumber> ">" ;
<columnFamilyName> ::= ( ksname=<cfOrKsName> dot="." )? cfname=<cfOrKsName> ;
<materializedViewName> ::= ( ksname=<cfOrKsName> dot="." )? mvname=<cfOrKsName> ;
@ -920,9 +922,9 @@ def insert_newval_completer(ctxt, cass):
return []
curcol = insertcols[len(valuesdone)]
coltype = layout.columns[curcol].cql_type
if coltype in ('map', 'set'):
if coltype.startswith('map<') or coltype.startswith('set<'):
return ['{']
if coltype == 'list':
if coltype.startswith('list<') or coltype.startswith('vector<'):
return ['[']
if coltype == 'boolean':
return ['true', 'false']
@ -997,10 +999,10 @@ def update_countername_completer(ctxt, cass):
coltype = layout.columns[curcol].cql_type
if coltype == 'counter':
return [maybe_escape_name(curcol)]
if coltype in ('map', 'set'):
return ["{"]
if coltype == 'list':
return ["["]
if coltype.startswith('map<') or coltype.startswith('set<'):
return ['{']
if coltype.startswith('list<') or coltype.startswith('vector<'):
return ['[']
return [Hint('<term (%s)>' % coltype)]
@ -1063,7 +1065,7 @@ def assignment_udt_field_completer(ctxt, cass):
def _is_usertype(layout, curcol):
coltype = layout.columns[curcol].cql_type
return coltype not in simple_cql_types and coltype not in ('map', 'set', 'list')
return coltype not in simple_cql_types and coltype not in ('map', 'set', 'list', 'vector')
def _usertype_fields(ctxt, cass, layout, curcol):

View File

@ -210,17 +210,17 @@ class TestCqlshCompletion(CqlshCompletionCase):
self.trycompletions(
'INSERT INTO twenty_rows_composite_table (a, b, c) VALUES (',
['<value for a (text)>'],
choices=['<value for a (text)>'],
split_completed_lines=False)
self.trycompletions(
"INSERT INTO twenty_rows_composite_table (a, b, c) VALUES ('",
['<value for a (text)>'],
choices=['<value for a (text)>'],
split_completed_lines=False)
self.trycompletions(
"INSERT INTO twenty_rows_composite_table (a, b, c) VALUES ( 'eggs",
['<value for a (text)>'],
choices=['<value for a (text)>'],
split_completed_lines=False)
self.trycompletions(
@ -230,7 +230,7 @@ class TestCqlshCompletion(CqlshCompletionCase):
self.trycompletions(
("INSERT INTO twenty_rows_composite_table (a, b, c) "
"VALUES ( 'eggs',"),
['<value for b (text)>'],
choices=['<value for b (text)>'],
split_completed_lines=False)
self.trycompletions(
@ -323,6 +323,22 @@ class TestCqlshCompletion(CqlshCompletionCase):
"VALUES ( 'eggs', 'sausage', 'spam') USING TTL 0 AND TIMESTAMP 0 AND "),
choices=[])
self.trycompletions(
("INSERT INTO has_all_types (num, setcol) VALUES (0, "),
immediate="{ ")
self.trycompletions(
("INSERT INTO has_all_types (num, mapcol) VALUES (0, "),
immediate="{ ")
self.trycompletions(
("INSERT INTO has_all_types (num, listcol) VALUES (0, "),
immediate="[ ")
self.trycompletions(
("INSERT INTO has_all_types (num, vectorcol) VALUES (0, "),
immediate="[ ")
def test_complete_in_update(self):
self.trycompletions("UPD", immediate="ATE ")
self.trycompletions("UPDATE ",
@ -631,6 +647,18 @@ class TestCqlshCompletion(CqlshCompletionCase):
self.trycompletions(prefix + ' new_table (col_a int PRIMARY KEY ',
choices=[')', ','])
self.trycompletions(prefix + ' new_table (col_a v',
choices=['varchar', 'varint', 'vector'])
self.trycompletions(prefix + ' new_table (col_a ve',
immediate='ctor ')
self.trycompletions(prefix + ' new_table (col_a vector<',
choices=['address', 'boolean', 'duration', 'list'],
other_choices_ok=True)
self.trycompletions(prefix + ' new_table (col_a vector<float, ',
choices=['<wholenumber>'])
self.trycompletions(prefix + ' new_table (col_a vector<float, 2 ',
immediate='>')
self.trycompletions(prefix + ' new_table (col_a int PRIMARY KEY,',
choices=['<identifier>', '<quotedName>'])
self.trycompletions(prefix + ' new_table (col_a int PRIMARY KEY)',

View File

@ -307,9 +307,9 @@ class TestCqlshOutput(BaseTestCase):
# same query should show up as empty in cql 3
self.assertQueriesGiveColoredOutput((
(q, """
num | asciicol | bigintcol | blobcol | booleancol | decimalcol | doublecol | durationcol | floatcol | intcol | smallintcol | textcol | timestampcol | tinyintcol | uuidcol | varcharcol | varintcol
RRR MMMMMMMM MMMMMMMMM MMMMMMM MMMMMMMMMM MMMMMMMMMM MMMMMMMMM MMMMMMMMMMM MMMMMMMM MMMMMM MMMMMMMMMMM MMMMMMM MMMMMMMMMMMM MMMMMMMMMM MMMMMMM MMMMMMMMMM MMMMMMMMM
-----+----------+-----------+---------+------------+------------+-----------+-------------+----------+--------+-------------+---------+--------------+------------+---------+------------+-----------
num | asciicol | bigintcol | blobcol | booleancol | decimalcol | doublecol | durationcol | floatcol | intcol | listcol | mapcol | setcol | smallintcol | textcol | timestampcol | tinyintcol | uuidcol | varcharcol | varintcol | vectorcol
RRR MMMMMMMM MMMMMMMMM MMMMMMM MMMMMMMMMM MMMMMMMMMM MMMMMMMMM MMMMMMMMMMM MMMMMMMM MMMMMM MMMMMMM MMMMMM MMMMMM MMMMMMMMMMM MMMMMMM MMMMMMMMMMMM MMMMMMMMMM MMMMMMM MMMMMMMMMM MMMMMMMMM MMMMMMMMM
-----+----------+-----------+---------+------------+------------+-----------+-------------+----------+--------+---------+--------+--------+-------------+---------+--------------+------------+---------+------------+-----------+-----------
(0 rows)
@ -675,7 +675,11 @@ class TestCqlshOutput(BaseTestCase):
tinyintcol tinyint,
uuidcol uuid,
varcharcol text,
varintcol varint
varintcol varint,
vectorcol vector<float, 3>,
listcol list<text>,
mapcol map<text, int>,
setcol set<text>
) WITH additional_write_policy = '99p'
AND allow_auto_snapshot = true
AND bloom_filter_fp_chance = 0.01

View File

@ -33,38 +33,50 @@ CREATE TABLE has_all_types (
tinyintcol tinyint,
uuidcol uuid,
varcharcol varchar,
varintcol varint
varintcol varint,
listcol list<text>,
setcol set<text>,
mapcol map<text, int>,
vectorcol vector<float, 3>,
) WITH compression = {'class':'LZ4Compressor'};
INSERT INTO has_all_types (num, intcol, asciicol, bigintcol, blobcol, booleancol,
decimalcol, doublecol, durationcol, floatcol, smallintcol, textcol,
timestampcol, tinyintcol, uuidcol, varcharcol, varintcol)
timestampcol, tinyintcol, uuidcol, varcharcol, varintcol,
listcol, setcol, mapcol, vectorcol)
VALUES (0, -12, 'abcdefg', 1234567890123456789, 0x000102030405fffefd, true,
19952.11882, 1.0, 12h, -2.1, 32767, 'Voilá!',
'2012-05-14 12:53:20+0000', 127, bd1924e1-6af8-44ae-b5e1-f24131dbd460, '"', 10000000000000000000000000);
'2012-05-14 12:53:20+0000', 127, bd1924e1-6af8-44ae-b5e1-f24131dbd460, '"', 10000000000000000000000000,
['a', 'b', 'c'], {'a', 'b', 'c'}, {'a': 1, 'b': 2, 'c': 3}, [1.0, 2.0, 3.0]);
INSERT INTO has_all_types (num, intcol, asciicol, bigintcol, blobcol, booleancol,
decimalcol, doublecol, durationcol, floatcol, smallintcol, textcol,
timestampcol, tinyintcol, uuidcol, varcharcol, varintcol)
timestampcol, tinyintcol, uuidcol, varcharcol, varintcol,
listcol, setcol, mapcol, vectorcol)
VALUES (1, 2147483647, '__!''$#@!~"', 9223372036854775807, 0xffffffffffffffffff, true,
0.00000000000001, 9999999.999, 12h30m, 99999.999, 32767, '∭Ƕ⑮ฑ➳❏''',
'1950-01-01+0000', 127, ffffffff-ffff-ffff-ffff-ffffffffffff, 'newline->
<-', 9);
<-', 9,
['__!''$#@!~"'], {'__!''$#@!~"'}, {'__!''$#@!~"': 2147483647}, [1, -2.0, NaN]);
INSERT INTO has_all_types (num, intcol, asciicol, bigintcol, blobcol, booleancol,
decimalcol, doublecol, durationcol, floatcol, smallintcol, textcol,
timestampcol, tinyintcol, uuidcol, varcharcol, varintcol)
timestampcol, tinyintcol, uuidcol, varcharcol, varintcol,
listcol, setcol, mapcol, vectorcol)
VALUES (2, 0, '', 0, 0x, false,
0.0, 0.0, 12h30m30s, 0.0, 0, '',
0, 0, 00000000-0000-0000-0000-000000000000, '', 0);
0, 0, 00000000-0000-0000-0000-000000000000, '', 0,
[], {}, {}, [0.0, 0.0, 0.0]);
INSERT INTO has_all_types (num, intcol, asciicol, bigintcol, blobcol, booleancol,
decimalcol, doublecol, durationcol, floatcol, smallintcol, textcol,
timestampcol, tinyintcol, uuidcol, varcharcol, varintcol)
timestampcol, tinyintcol, uuidcol, varcharcol, varintcol,
listcol, setcol, mapcol, vectorcol)
VALUES (3, -2147483648, '''''''', -9223372036854775808, 0x80, false,
10.0000000000000, -1004.10, 12h30m30s250ms, 100000000.9, 32767, '龍馭鬱',
'2038-01-19T03:14-1200', 127, ffffffff-ffff-1fff-8fff-ffffffffffff,
'''', -10000000000000000000000000);
'''', -10000000000000000000000000,
['龍馭鬱'], {'龍馭鬱'}, {'龍馭鬱': -2147483648}, [100000000.9, 100000000.9, 100000000.9]);
INSERT INTO has_all_types (num, intcol, asciicol, bigintcol, blobcol, booleancol,
decimalcol, doublecol, floatcol, smallintcol, textcol,