-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove CqlType in favor of ColumnType #1166
Draft
Lorak-mmk
wants to merge
66
commits into
scylladb:main
Choose a base branch
from
Lorak-mmk:new_column_type
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
As Connection's methods are mainly intended for private use by Connection itself or by the abstractions from connection_pool.rs exclusively, their visibility was reduced to `pub(self)` or `pub(super)`, respectively. Let's make our assumptions about layer separation enforced by the module visibility rules.
perform_authenticate takes `&mut Connection` as its first argument, which makes it a perfect suit to become a method on Connection.
As other drivers do, Rust driver will hold all user-implementable policies in one module for easier access by interested code-reading users.
`scylla::retry` is not an intuitive name for a path. `scylla::policies::retry` should be the way to reference the module with retry policies.
`scylla::speculative_execution` is not an intuitive name for a path. `scylla::policies::speculative_execution` should be the way to reference the module with speculative execution policies.
`scylla::load_balancing` is not an intuitive name for a path. `scylla::policies::load_balancing` should be the way to reference the module with load balancing policies.
`scylla::host_filter` is not an intuitive name for a path. `scylla::policies::host_filter` should be the way to reference the module with host filter.
Previously this method accepted a map with UDTs for all keyspaces. This is not necessary: UDTs in one keyspace can not reference UDTs in another keyspace.
This function performs a request that fetches columns for all tables and views. It is potentially the most performance-impactful part of the schema fetching process, and it was unnecessarily called twice: in query_tables and in query_views. It can be easily prevented by calling the function earlier and passing the result to query_tables and query_views.
MissingUserDefinedType was an obstacle preventing us from unifying ColumnType and CqlType. This commit changes the topology fetching code to remove the keyspace where such an error happened from the metadata. A warning is printed in such case.
It is no longer part of any public API.
This commit changes type of `keyspaces` field in `Metadata` from `HashMap<String, Keyspace>` to `HashMap<String, Result<Keyspace, MissingUserDefinedType>>`. Because of that, it also removed `MissingUserDefinedType` handling from `query_metadata`. Now handling this error is done in `ClusterData::new`. This has an advantage: we can use older version of the keyspace metadata if the new version has this error.
As part of an effort to unify CqlType with ColumnType we need to make those types compatible enough. First part of this is extracting simple types from ColumnType into their own enum.
As part of an effort to unify CqlType with ColumnType we need to make those types compatible enough. This commit extracts collection types into their own sub-type.
As part of an effort to unify CqlType with ColumnType we need to make those types compatible enough. CqlType stored UserDefinedType as a separate struct under Arc, in order to share it between different metadata structures. This commit does the same for ColumnType. Note that the field for UDT name is now "name" instead of the "type_name", because the old one was a bit redundant.
This is done to keep this field name the same as in ColumnType.
For now without any capability for serialization or deserialization. This is necessary for unification of CqlType and ColumnType.
This is the last step towards making CqlType and ColumnType (mostly) identical. After this change the only difference is that ColumnType may use borrowed data, and thus has a lifetime parameter.
This will make it easier to remove CqlType completely.
Removed types: CqlType, CollectionType, NativeType. Their usages are replaced with the relevant types from scylla_cql. Fixes: scylladb#691
This is more consistent after removing CqlType in favor of ColumnType.
Lorak-mmk
force-pushed
the
new_column_type
branch
from
January 9, 2025 12:07
4d30a3c
to
6a9be35
Compare
github-actions
bot
added
the
semver-checks-breaking
cargo-semver-checks reports that this PR introduces breaking API changes
label
Jan 9, 2025
See the following report for details: cargo semver-checks output
|
8 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
API-stability
Part of the effort to stabilize the API
semver-checks-breaking
cargo-semver-checks reports that this PR introduces breaking API changes
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR removes
CqlType
(used in schema metadata) and replaces its usages withColumnType
(used in statement metadata).Initially those two structures were quite different, so most of the commits are done to make them mostly identical, which made the unification possible.
Layout
CqlType was split into subtypes (native type, collection type, tuple, UDT) as defined by https://cassandra.apache.org/doc/stable/cassandra/cql/types.html
ColumnType was fully inlined - it had a variant for each possible type.
I decided to change ColumnType in this regard to follow CqlType, because CqlType's approach seems to be much more elegant.
Frozen flag
CqlType contained frozen flag, because the schema contains information about whether the collection/UDT is frozen or not.
ColumnType did not contain such flag, because this information is not present in result metadata / arguments metadata.
There wasn't any real choice - we have to store the frozen flag to accurately represent the schema metadata.
For types used in statements, this flag is simply always set to false.
UDT shared ownership
ColumnType stored the UDT data inline, this is how the variant looked:
CqlType stored it in a separate struct, which was held under Arc:
This is because it may be stored in a few places:
Keyspace::user_defined_types
This requires either cloning, or shared ownership.
Custom type
ColumnType had a variant for Custom type, because it is defined by the protocol.
However, this type is rarely used, and we don't really have any working support for it, so I decided to remove it.
Minor changes
I decided to change the size type of Vector to u16. It frees any users of this struct from dealing with negative numbers (which are disallowed by the protocol, and make no sense here).
Fixes #691
Pre-review checklist
./docs/source/
.Fixes:
annotations to PR description.