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

Add support for custom CQL types #364

Closed
psarna opened this issue Dec 5, 2021 · 5 comments
Closed

Add support for custom CQL types #364

psarna opened this issue Dec 5, 2021 · 5 comments
Assignees
Labels
API-breaking This might introduce incompatible API changes

Comments

@psarna
Copy link
Contributor

psarna commented Dec 5, 2021

CQL v4 spec mentions that aside from native types, it's also possible to return a custom type. Excerpt from the spec: https://github.com/apache/cassandra/blob/trunk/doc/native_protocol_v4.spec

The option for <type> is either a native
          type (see below), in which case the option has no value, or a
          'custom' type, in which case the value is a [string] representing
          the fully qualified class name of the type represented. Valid option
          ids are:
            0x0000    Custom: the value is a [string], see above.
            0x0001    Ascii
            0x0002    Bigint
            0x0003    Blob

We currently don't support any custom types, but given the problem described in #363 where Cassandra returns duration as a custom type, we should add a mechanism for implementing such support.

psarna added a commit that referenced this issue Dec 24, 2021
CQL protocol allows sending custom types identified by their
string representation. One of the cases in which the trick is used
is when Cassandra returns duration columns to a CQLv4 client, which
is not supposed to know this type.

WIP: the actual implementation will be done once #363 is merged.

Refs #364
psarna added a commit that referenced this issue Mar 17, 2022
CQL protocol allows sending custom types identified by their
string representation. One of the cases in which the trick is used
is when Cassandra returns duration columns to a CQLv4 client, which
is not supposed to know this type.

WIP: the actual implementation will be done once #363 is merged.

Refs #364
piodul pushed a commit that referenced this issue Mar 17, 2022
CQL protocol allows sending custom types identified by their
string representation. One of the cases in which the trick is used
is when Cassandra returns duration columns to a CQLv4 client, which
is not supposed to know this type.

Refs #364

Closes #368
@piodul
Copy link
Collaborator

piodul commented Apr 1, 2022

In #363, we gained a (hardcoded) support for deserializing org.apache.cassandra.db.marshal.DurationType as Duration - this is how Cassandra serializes the Duration type in the v4 of the CQL protocol. Other custom types still aren't supported.

@piodul piodul added the API-breaking This might introduce incompatible API changes label Mar 28, 2023
@Lorak-mmk Lorak-mmk self-assigned this Nov 15, 2023
@avelanarius
Copy link

Should we close this issue as not planned?

  • We have already covered the org.apache.cassandra.db.marshal.DurationType use case
  • I don't think there are future plans to use custom types in ScyllaDB
  • Custom types are deprecated in Cassandra:

    Custom types exists mostly for backward compatibility purposes and their usage is discouraged. Their usage is complex, not user friendly and the other provided types, particularly user-defined types, should almost always be enough.

@piodul
Copy link
Collaborator

piodul commented Feb 20, 2024

Yes, given your arguments @avelanarius I think it makes sense to close. Serializing/deserializing such types should be possible if somebody provides custom implementations of the relevant traits (for deserialization, it will require #462). As they are deprecated, we don't need to care about them in CqlValue.

@Lorak-mmk what do you think?

@Lorak-mmk
Copy link
Collaborator

I think (but am not sure) that it is currently possible to serialize such values (by manually implementing SerializeCql) and so insert them into database.
Regarding deserialization, in the examples directory we have custom_deserialization.rs example and I think it should nearly allow selecting such a type - I suspect the only thing missing is adding a Custom variant to CqlValue.
So making it possible (but not easy) to operate on custom type should be a pretty simple task. But given arguments from @avelanarius that is probably unnecessary work and we should close this issue. This is also an issue opened by us - are we aware of any users actually wanting this feature?

One thing to note is that it won't be possible to implement this after 1.0 (without releasing 2.0) unless we mark CqlValue as non-exhaustive.

@wprzytula
Copy link
Collaborator

But given arguments from @avelanarius that is probably unnecessary work and we should close this issue.

I'm convinced fully, Custom is a pure legacy, UDT is the present and the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API-breaking This might introduce incompatible API changes
Projects
None yet
Development

No branches or pull requests

5 participants