Skip to content

Fix vector type formatting error in cqlsh#165

Merged
fruch merged 1 commit intoscylladb:masterfrom
swasik:VECTOR-563-select-all-formatting
Mar 12, 2026
Merged

Fix vector type formatting error in cqlsh#165
fruch merged 1 commit intoscylladb:masterfrom
swasik:VECTOR-563-select-all-formatting

Conversation

@swasik
Copy link
Contributor

@swasik swasik commented Mar 12, 2026

CqlType.parse() treated vector<float, 5> as having two subtypes [float, 5]. When formatting a 5-element vector, get_n_sub_types(5) failed because len(sub_types) == 2 matched neither the tuple case (== num) nor the list/set case (== 1), raising:
'Unexpected number of subtypes 5 - [float, 5]'

Fix: when parsing a vector<type, dimension> type string, discard the dimension and keep only the element type as a single subtype. This lets get_n_sub_types() replicate the element type for each value in the vector, matching the existing list/set code path.

Added test_vector_formatting.py with 8 tests covering CqlType parsing and end-to-end value formatting for various vector types.

Fixes: VECTOR-563

CqlType.parse() treated vector<float, 5> as having two subtypes [float, 5].
When formatting a 5-element vector, get_n_sub_types(5) failed because
len(sub_types) == 2 matched neither the tuple case (== num) nor the
list/set case (== 1), raising:
  'Unexpected number of subtypes 5 - [float, 5]'

Fix: when parsing a vector<type, dimension> type string, discard the
dimension and keep only the element type as a single subtype. This
lets get_n_sub_types() replicate the element type for each value in
the vector, matching the existing list/set code path.

Added test_vector_formatting.py with 8 tests covering CqlType parsing
and end-to-end value formatting for various vector types.

Fixes: VECTOR-563
@swasik swasik requested a review from fruch March 12, 2026 10:15
@github-actions github-actions bot added the P2 label Mar 12, 2026
@swasik
Copy link
Contributor Author

swasik commented Mar 12, 2026

Failing test is known issue: #164

Copy link
Collaborator

@fruch fruch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@fruch fruch merged commit 57244db into scylladb:master Mar 12, 2026
15 of 16 checks passed
@fruch
Copy link
Collaborator

fruch commented Mar 12, 2026

@swasik now you can pull it in scylla code, and get it updated there

@swasik
Copy link
Contributor Author

swasik commented Mar 13, 2026

@swasik now you can pull it in scylla code, and get it updated there

What exactly should I do? It's the first time I contribute to cqlsh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants