Skip to content
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

Merged
merged 20 commits into from
Jan 29, 2025

Conversation

Lorak-mmk
Copy link
Collaborator

@Lorak-mmk Lorak-mmk commented Jan 9, 2025

This PR removes CqlType (used in schema metadata) and replaces its usages with ColumnType (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:

    UserDefinedType {
        type_name: Cow<'frame, str>,
        keyspace: Cow<'frame, str>,
        field_types: Vec<(Cow<'frame, str>, ColumnType<'frame>)>,
    },

CqlType stored it in a separate struct, which was held under Arc:

/// Definition of a user-defined type
    UserDefinedType {
        frozen: bool,
        // Using Arc here in order not to have many copies of the same definition
        definition: Arc<UserDefinedType>,
    },
...

#[derive(Clone, Debug, PartialEq, Eq)]
pub struct UserDefinedType {
    pub name: String,
    pub keyspace: String,
    pub field_types: Vec<(String, CqlType)>,
}

This is because it may be stored in a few places:

  • Keyspace::user_defined_types
  • As a field in another UDT
  • As a column in the table
  • As a column in the view

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

  • I have split my patch into logically separate commits.
  • All commit messages clearly explain what they change and why.
  • I added relevant tests for new features and bug fixes.
  • All commits compile, pass static checks and pass test.
  • PR description sums up the changes and reasons why they should be introduced.
  • I have provided docstrings for the public items that I want to introduce.
  • I have adjusted the documentation in ./docs/source/. - Nothing to adjust
  • I added appropriate Fixes: annotations to PR description.

@Lorak-mmk Lorak-mmk marked this pull request as draft January 9, 2025 12:04
@github-actions github-actions bot added the semver-checks-breaking cargo-semver-checks reports that this PR introduces breaking API changes label Jan 9, 2025
Copy link

github-actions bot commented Jan 9, 2025

cargo semver-checks detected some API incompatibilities in this PR.
Checked commit: cfeb8b9

See the following report for details:

cargo semver-checks output
./scripts/semver-checks.sh --baseline-rev b6a3e01d8aec2842352d193b54f09ccaedfcbcbf
+ cargo semver-checks -p scylla -p scylla-cql --baseline-rev b6a3e01d8aec2842352d193b54f09ccaedfcbcbf
     Cloning b6a3e01d8aec2842352d193b54f09ccaedfcbcbf
    Building scylla v0.15.0 (current)
       Built [  24.325s] (current)
     Parsing scylla v0.15.0 (current)
      Parsed [   0.051s] (current)
    Building scylla v0.15.0 (baseline)
       Built [  22.502s] (baseline)
     Parsing scylla v0.15.0 (baseline)
      Parsed [   0.050s] (baseline)
    Checking scylla v0.15.0 -> v0.15.0 (no change)
     Checked [   0.144s] 127 checks: 123 pass, 4 fail, 0 warn, 0 skip

--- failure constructible_struct_adds_field: externally-constructible struct adds field ---

Description:
A pub struct constructible with a struct literal has a new pub field. Existing struct literals must be updated to include the new field.
        ref: https://doc.rust-lang.org/reference/expressions/struct-expr.html
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.39.0/src/lints/constructible_struct_adds_field.ron

Failed in:
  field Column.typ in /home/runner/work/scylla-rust-driver/scylla-rust-driver/scylla/src/cluster/metadata.rs:208

--- failure enum_missing: pub enum removed or renamed ---

Description:
A publicly-visible enum cannot be imported by its prior path. A `pub use` may have been removed, or the enum itself may have been renamed or removed entirely.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.39.0/src/lints/enum_missing.ron

Failed in:
  enum scylla::cluster::metadata::CqlType, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-b6a3e01d8aec2842352d193b54f09ccaedfcbcbf/0693068e3bfa5b13fdac54af42ffeba4d62b4be0/scylla/src/cluster/metadata.rs:269
  enum scylla::cluster::metadata::CollectionType, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-b6a3e01d8aec2842352d193b54f09ccaedfcbcbf/0693068e3bfa5b13fdac54af42ffeba4d62b4be0/scylla/src/cluster/metadata.rs:392
  enum scylla::cluster::metadata::NativeType, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-b6a3e01d8aec2842352d193b54f09ccaedfcbcbf/0693068e3bfa5b13fdac54af42ffeba4d62b4be0/scylla/src/cluster/metadata.rs:306

--- failure struct_missing: pub struct removed or renamed ---

Description:
A publicly-visible struct cannot be imported by its prior path. A `pub use` may have been removed, or the struct itself may have been renamed or removed entirely.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.39.0/src/lints/struct_missing.ron

Failed in:
  struct scylla::cluster::metadata::UserDefinedType, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-b6a3e01d8aec2842352d193b54f09ccaedfcbcbf/0693068e3bfa5b13fdac54af42ffeba4d62b4be0/scylla/src/cluster/metadata.rs:291
  struct scylla::cluster::metadata::NativeTypeFromStrError, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-b6a3e01d8aec2842352d193b54f09ccaedfcbcbf/0693068e3bfa5b13fdac54af42ffeba4d62b4be0/scylla/src/cluster/metadata.rs:331

--- failure struct_pub_field_missing: pub struct's pub field removed or renamed ---

Description:
A publicly-visible struct has at least one public field that is no longer available under its prior name. It may have been renamed or removed entirely.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.39.0/src/lints/struct_pub_field_missing.ron

Failed in:
  field type_ of struct Column, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-b6a3e01d8aec2842352d193b54f09ccaedfcbcbf/0693068e3bfa5b13fdac54af42ffeba4d62b4be0/scylla/src/cluster/metadata.rs:203

     Summary semver requires new major version: 4 major and 0 minor checks failed
    Finished [  47.970s] scylla
    Building scylla-cql v0.4.0 (current)
       Built [  11.347s] (current)
     Parsing scylla-cql v0.4.0 (current)
      Parsed [   0.033s] (current)
    Building scylla-cql v0.4.0 (baseline)
       Built [  11.148s] (baseline)
     Parsing scylla-cql v0.4.0 (baseline)
      Parsed [   0.033s] (baseline)
    Checking scylla-cql v0.4.0 -> v0.4.0 (no change)
     Checked [   0.125s] 127 checks: 123 pass, 4 fail, 0 warn, 0 skip

--- failure enum_struct_variant_field_added: pub enum struct variant field added ---

Description:
An enum's exhaustive struct variant has a new field, which has to be included when constructing or matching on this variant.
        ref: https://doc.rust-lang.org/reference/attributes/type_system.html#the-non_exhaustive-attribute
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.39.0/src/lints/enum_struct_variant_field_added.ron

Failed in:
  field name of variant CqlValue::UserDefinedType in /home/runner/work/scylla-rust-driver/scylla-rust-driver/scylla-cql/src/frame/response/result.rs:217
  field frozen of variant ColumnType::UserDefinedType in /home/runner/work/scylla-rust-driver/scylla-rust-driver/scylla-cql/src/frame/response/result.rs:83
  field definition of variant ColumnType::UserDefinedType in /home/runner/work/scylla-rust-driver/scylla-rust-driver/scylla-cql/src/frame/response/result.rs:84

--- failure enum_struct_variant_field_missing: pub enum struct variant's field removed or renamed ---

Description:
A publicly-visible enum has a struct variant whose field is no longer available under its prior name. It may have been renamed or removed entirely.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.39.0/src/lints/enum_struct_variant_field_missing.ron

Failed in:
  field type_name of variant ColumnType::UserDefinedType, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-b6a3e01d8aec2842352d193b54f09ccaedfcbcbf/0693068e3bfa5b13fdac54af42ffeba4d62b4be0/scylla-cql/src/frame/response/result.rs:73
  field keyspace of variant ColumnType::UserDefinedType, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-b6a3e01d8aec2842352d193b54f09ccaedfcbcbf/0693068e3bfa5b13fdac54af42ffeba4d62b4be0/scylla-cql/src/frame/response/result.rs:74
  field field_types of variant ColumnType::UserDefinedType, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-b6a3e01d8aec2842352d193b54f09ccaedfcbcbf/0693068e3bfa5b13fdac54af42ffeba4d62b4be0/scylla-cql/src/frame/response/result.rs:75
  field type_name of variant CqlValue::UserDefinedType, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-b6a3e01d8aec2842352d193b54f09ccaedfcbcbf/0693068e3bfa5b13fdac54af42ffeba4d62b4be0/scylla-cql/src/frame/response/result.rs:160

--- failure enum_variant_added: enum variant added on exhaustive enum ---

Description:
A publicly-visible enum without #[non_exhaustive] has a new variant.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#enum-variant-new
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.39.0/src/lints/enum_variant_added.ron

Failed in:
  variant ColumnType:Native in /home/runner/work/scylla-rust-driver/scylla-rust-driver/scylla-cql/src/frame/response/result.rs:64
  variant ColumnType:Collection in /home/runner/work/scylla-rust-driver/scylla-rust-driver/scylla-cql/src/frame/response/result.rs:68
  variant ColumnType:Vector in /home/runner/work/scylla-rust-driver/scylla-rust-driver/scylla-cql/src/frame/response/result.rs:76

--- failure enum_variant_missing: pub enum variant removed or renamed ---

Description:
A publicly-visible enum has at least one variant that is no longer available under its prior name. It may have been renamed or removed entirely.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.39.0/src/lints/enum_variant_missing.ron

Failed in:
  variant BuiltinDeserializationErrorKind::CustomTypeNotSupported, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-b6a3e01d8aec2842352d193b54f09ccaedfcbcbf/0693068e3bfa5b13fdac54af42ffeba4d62b4be0/scylla-cql/src/deserialize/value.rs:1782
  variant BuiltinTypeCheckErrorKind::CustomTypeUnsupported, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-b6a3e01d8aec2842352d193b54f09ccaedfcbcbf/0693068e3bfa5b13fdac54af42ffeba4d62b4be0/scylla-cql/src/serialize/value.rs:1152
  variant ColumnType::Custom, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-b6a3e01d8aec2842352d193b54f09ccaedfcbcbf/0693068e3bfa5b13fdac54af42ffeba4d62b4be0/scylla-cql/src/frame/response/result.rs:54
  variant ColumnType::Ascii, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-b6a3e01d8aec2842352d193b54f09ccaedfcbcbf/0693068e3bfa5b13fdac54af42ffeba4d62b4be0/scylla-cql/src/frame/response/result.rs:55
  variant ColumnType::Boolean, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-b6a3e01d8aec2842352d193b54f09ccaedfcbcbf/0693068e3bfa5b13fdac54af42ffeba4d62b4be0/scylla-cql/src/frame/response/result.rs:56
  variant ColumnType::Blob, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-b6a3e01d8aec2842352d193b54f09ccaedfcbcbf/0693068e3bfa5b13fdac54af42ffeba4d62b4be0/scylla-cql/src/frame/response/result.rs:57
  variant ColumnType::Counter, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-b6a3e01d8aec2842352d193b54f09ccaedfcbcbf/0693068e3bfa5b13fdac54af42ffeba4d62b4be0/scylla-cql/src/frame/response/result.rs:58
  variant ColumnType::Date, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-b6a3e01d8aec2842352d193b54f09ccaedfcbcbf/0693068e3bfa5b13fdac54af42ffeba4d62b4be0/scylla-cql/src/frame/response/result.rs:59
  variant ColumnType::Decimal, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-b6a3e01d8aec2842352d193b54f09ccaedfcbcbf/0693068e3bfa5b13fdac54af42ffeba4d62b4be0/scylla-cql/src/frame/response/result.rs:60
  variant ColumnType::Double, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-b6a3e01d8aec2842352d193b54f09ccaedfcbcbf/0693068e3bfa5b13fdac54af42ffeba4d62b4be0/scylla-cql/src/frame/response/result.rs:61
  variant ColumnType::Duration, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-b6a3e01d8aec2842352d193b54f09ccaedfcbcbf/0693068e3bfa5b13fdac54af42ffeba4d62b4be0/scylla-cql/src/frame/response/result.rs:62
  variant ColumnType::Float, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-b6a3e01d8aec2842352d193b54f09ccaedfcbcbf/0693068e3bfa5b13fdac54af42ffeba4d62b4be0/scylla-cql/src/frame/response/result.rs:63
  variant ColumnType::Int, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-b6a3e01d8aec2842352d193b54f09ccaedfcbcbf/0693068e3bfa5b13fdac54af42ffeba4d62b4be0/scylla-cql/src/frame/response/result.rs:64
  variant ColumnType::BigInt, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-b6a3e01d8aec2842352d193b54f09ccaedfcbcbf/0693068e3bfa5b13fdac54af42ffeba4d62b4be0/scylla-cql/src/frame/response/result.rs:65
  variant ColumnType::Text, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-b6a3e01d8aec2842352d193b54f09ccaedfcbcbf/0693068e3bfa5b13fdac54af42ffeba4d62b4be0/scylla-cql/src/frame/response/result.rs:66
  variant ColumnType::Timestamp, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-b6a3e01d8aec2842352d193b54f09ccaedfcbcbf/0693068e3bfa5b13fdac54af42ffeba4d62b4be0/scylla-cql/src/frame/response/result.rs:67
  variant ColumnType::Inet, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-b6a3e01d8aec2842352d193b54f09ccaedfcbcbf/0693068e3bfa5b13fdac54af42ffeba4d62b4be0/scylla-cql/src/frame/response/result.rs:68
  variant ColumnType::List, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-b6a3e01d8aec2842352d193b54f09ccaedfcbcbf/0693068e3bfa5b13fdac54af42ffeba4d62b4be0/scylla-cql/src/frame/response/result.rs:69
  variant ColumnType::Map, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-b6a3e01d8aec2842352d193b54f09ccaedfcbcbf/0693068e3bfa5b13fdac54af42ffeba4d62b4be0/scylla-cql/src/frame/response/result.rs:70
  variant ColumnType::Set, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-b6a3e01d8aec2842352d193b54f09ccaedfcbcbf/0693068e3bfa5b13fdac54af42ffeba4d62b4be0/scylla-cql/src/frame/response/result.rs:71
  variant ColumnType::SmallInt, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-b6a3e01d8aec2842352d193b54f09ccaedfcbcbf/0693068e3bfa5b13fdac54af42ffeba4d62b4be0/scylla-cql/src/frame/response/result.rs:77
  variant ColumnType::TinyInt, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-b6a3e01d8aec2842352d193b54f09ccaedfcbcbf/0693068e3bfa5b13fdac54af42ffeba4d62b4be0/scylla-cql/src/frame/response/result.rs:78
  variant ColumnType::Time, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-b6a3e01d8aec2842352d193b54f09ccaedfcbcbf/0693068e3bfa5b13fdac54af42ffeba4d62b4be0/scylla-cql/src/frame/response/result.rs:79
  variant ColumnType::Timeuuid, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-b6a3e01d8aec2842352d193b54f09ccaedfcbcbf/0693068e3bfa5b13fdac54af42ffeba4d62b4be0/scylla-cql/src/frame/response/result.rs:80
  variant ColumnType::Uuid, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-b6a3e01d8aec2842352d193b54f09ccaedfcbcbf/0693068e3bfa5b13fdac54af42ffeba4d62b4be0/scylla-cql/src/frame/response/result.rs:82
  variant ColumnType::Varint, previously in file /home/runner/work/scylla-rust-driver/scylla-rust-driver/target/semver-checks/git-b6a3e01d8aec2842352d193b54f09ccaedfcbcbf/0693068e3bfa5b13fdac54af42ffeba4d62b4be0/scylla-cql/src/frame/response/result.rs:83

     Summary semver requires new major version: 4 major and 0 minor checks failed
    Finished [  23.426s] scylla-cql
make: *** [Makefile:61: semver-rev] Error 1

@wprzytula wprzytula added the API-stability Part of the effort to stabilize the API label Jan 17, 2025
@Lorak-mmk Lorak-mmk force-pushed the new_column_type branch 2 times, most recently from b905b51 to 1eee540 Compare January 21, 2025 08:09
@Lorak-mmk Lorak-mmk self-assigned this Jan 21, 2025
@Lorak-mmk Lorak-mmk marked this pull request as ready for review January 21, 2025 08:16
@Lorak-mmk
Copy link
Collaborator Author

Rebased on main

@Lorak-mmk
Copy link
Collaborator Author

Again known failure with "Failed to apply group 0 change due to concurrent modification"...

If Core is not willing to address this problem then maybe we should introduce client-side retries for those queries?

scylla/src/utils/parse.rs Outdated Show resolved Hide resolved
scylla/src/cluster/metadata.rs Outdated Show resolved Hide resolved
/// matches the datatype used by the java driver:
/// <https://github.com/apache/cassandra-java-driver/blob/85bb4065098b887d2dda26eb14423ce4fc687045/core/src/main/java/com/datastax/oss/driver/api/core/type/DataTypes.java#L77>
dimensions: i32,
dimensions: u16,
Copy link
Contributor

@muzarski muzarski Jan 22, 2025

Choose a reason for hiding this comment

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

What about (u16::MAX, i32::MAX] values? I know that such values are impractical and probably will never appear there, but according to the specification it is possible, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Which specification?

  • CQLv5 binary protocol only mentions vectors once:
5.25 vector

  For a vector of n dimensions of a fixed-length type, a sequence of those n elements.
  For a vector with variable-length elements, the size of the elements will preced
  each element.  Each element is the [bytes] representing the serialized value.  The
  number of dimensions is not encoded, since it's part of the type definition.

There is no defined binary type encoding for vectors (which would give is the type to use for dimensions) - it is encoded as text (custom type) which is why #1165 needs to do so many changes.

Copy link
Contributor

Choose a reason for hiding this comment

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

* Cassandra docs say that the maximum amount of elements in a vector is 8K (2^13) which fits in u16: https://cassandra.apache.org/doc/latest/cassandra/reference/vector-data-type.html

Ok, this convinces me. I based my assumption on the code snippet (https://github.com/apache/cassandra-java-driver/blob/85bb4065098b887d2dda26eb14423ce4fc687045/core/src/main/java/com/datastax/oss/driver/api/core/type/DataTypes.java#L77). I forgot that Java does not have unsigned integral data types... But then, I believe that short data type in Java should be enough to store a value up to 8k. I wonder why they chose int.

Copy link
Collaborator Author

@Lorak-mmk Lorak-mmk Jan 23, 2025

Choose a reason for hiding this comment

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

I don't think they pay much attention to such things. If they did then CQL protocol wouldn't have such obvious issues unfixed for as long as it does now.

@@ -6,7 +6,7 @@ use crate as scylla;
use crate::batch::{Batch, BatchStatement};
Copy link
Contributor

Choose a reason for hiding this comment

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

commit Remove CqlType and related types - I expected this commit to contain a lot of changes. To my surprise, there are very few of them. Great job of splitting this PR into the commits - thanks to that the final replacement was trivial.

@Lorak-mmk
Copy link
Collaborator Author

Adrressed the comments

@wprzytula
Copy link
Collaborator

Again known failure with "Failed to apply group 0 change due to concurrent modification"...

If Core is not willing to address this problem then maybe we should introduce client-side retries for those queries?

This sounds like a good workaround.

scylla-cql/src/frame/response/result.rs Outdated Show resolved Hide resolved
scylla-cql/src/frame/response/result.rs Outdated Show resolved Hide resolved
scylla/src/cluster/metadata.rs Show resolved Hide resolved
scylla/src/utils/parse.rs Outdated Show resolved Hide resolved
scylla-cql/src/frame/response/result.rs Outdated Show resolved Hide resolved
scylla-cql/src/frame/response/result.rs Outdated Show resolved Hide resolved
scylla-cql/src/frame/response/result.rs Outdated Show resolved Hide resolved
scylla-cql/src/types/deserialize/value.rs Outdated Show resolved Hide resolved
scylla-cql/src/frame/response/result.rs Outdated Show resolved Hide resolved
scylla-cql/src/frame/response/result.rs Outdated Show resolved Hide resolved
@roydahan roydahan added this to the 0.16.0 milestone Jan 27, 2025
@Lorak-mmk
Copy link
Collaborator Author

Addressed all the review comments. I'll rebase on main in a separate push.

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.
We don't really support this type, and this removes is required for
unification of CqlType and ColumnType.
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.
@Lorak-mmk
Copy link
Collaborator Author

  • Rebased on main
  • Fixed an issue where the new types (NativeType) etc were not re-exported in scylla crate. Added a test for that in hygiene.rs

This is done to keep this field name the same as in ColumnType.
According to Cassandra documentation maximum size of the vector is 8K,
which fits fine in u16. Using unsigned type will be more pleasant to
users, because they won't need to deal with negative values.
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.
It is less ugly, and matches the convention in other parts of the driver.
It is less ugly, and matches the convention in other parts of the driver.
@Lorak-mmk
Copy link
Collaborator Author

Fixed CI errors. I'll run make ci again on all commits to ensure they work.

It is less ugly, and matches the convention in other parts of the driver.
It is less ugly, and matches the convention in other parts of the driver.
It is less ugly, and matches the convention in other parts of the driver.
It is less ugly, and matches the convention in other parts of the driver.
Those were the only remaining occurrences of `type_` identifier in the
driver.
scylla-cql/src/frame/response/result.rs Outdated Show resolved Hide resolved
scylla-cql/src/frame/response/result.rs Outdated Show resolved Hide resolved
scylla-cql/src/frame/response/result.rs Outdated Show resolved Hide resolved
@@ -1269,109 +1342,116 @@ pub fn deser_cql_value(
let v = Some(FrameSlice::new_borrowed(buf));
Copy link
Collaborator

Choose a reason for hiding this comment

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

📌 When removing the legacy deserialization framework, please check if it's possible to remove the workaround in FrameSlice: the new_borrowed constructor.

@Lorak-mmk Lorak-mmk merged commit 9441b05 into scylladb:main Jan 29, 2025
9 checks passed
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unify ColumnType and CqlType
4 participants