AlexPikalov / cdrs

Cassandra DB native client written in Rust language. Find 1.x versions on https://github.com/AlexPikalov/cdrs/tree/v.1.x Looking for an async version? - Check WIP https://github.com/AlexPikalov/cdrs-async

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CDRS driver does not support older Cassandra versions (2.x.x)

MaenMax opened this issue · comments

I was not able to connect the driver to Cassandra DB 2.1.16

The error message is attached

MicrosoftTeams-image

Could you please help to solve this issue for us ?

Hi @MaenMax

Probably this version of Cassandra uses version 3 of binary protocol.
Please try to use CDRS with feature v3. Put it into your Cargo.toml:

cdrs = { version = "2" features=["v3"] default-features = false }

or

cdrs = { version = "2" features=["v3", "ssl"] default-features = false }

if you use SSL.

It should help

I will try and let you know. Thanks!

I'm closing this issue.
If you find any problems working with CDRS and version 3 Cassandra binary protocol please feel free to re-open this issue or create a new one.
Thanks.

Hi Alex,
Thanks for your comment. I recompiled my project with the modification you pointed to, but with no success. I got this error:

Thread '' panicked at 'query: Server(CDRSError { error_code: 8704, message: CString { string: "Keyspace system_schema does not exist" }, additional_info: Invalid(SimpleError) })', src/libcore/result.rs:997:5
note: Run with RUST_BACKTRACE=1 environment variable to display a backtrace.

It looks like that CDRS driver expects some keyspace (system_schema) which did not exist in Cassandra versions 2.x.x. What's your thoughts on this?

Thanks,
Maen

Seems like somewhere in your code you use something like use system_schema; and, in your version of Cassandra seerver, such keyspace doesn't exist.

Thanks for your insights ! That's true, I use that in my code. Because I need to get the list of tables in a particular keyspace (and it actually worked well in Cassandra 3.x.x).

let describe_struct_cql = "SELECT table_name FROM system_schema.tables WHERE keyspace_name = 'autopush'";
    let rows = ddb
    .query(describe_struct_cql)
    .expect("query")
    .get_body()
    .expect("get body")
    .into_rows()
    .expect("into rows");

Cassandra older versions do not have the default system_schema keyspace which will allow me to get the list of tables. Now, I don't have any idea about how to do that in CDRS. At least, I know that in order to get the list of tables of a particular keyspace in Cassandra 2.1.x , there are two steps need to be done in cqlsh:

[1] use <keyspace_name> ;
[2] describe tables ;

To do that, I tried:

 let use_keyspace_cql = "use autopush;";
    
    ddb.query(use_keyspace_cql).expect("[Err]: CEP was not able to switch to autopush keyspace"); 
    
    let describe_struct_cql = "DESC tables";
    let rows = ddb
        .query(describe_struct_cql)
        .expect("query")
        .get_body()
        .expect("get body")
        .into_rows()
        .expect("into rows");

But I got:

thread '' panicked at 'query: Server(CDRSError { error_code: 8192, message: CString { string: "line 1:0 no viable alternative at input 'DESC' ([DESC]...)" }, additional_info: Syntax(SimpleError) })', src/libcore/result.rs:997:5
note: Run with RUST_BACKTRACE=1 environment variable to display a backtrace.

How to do that in CDRS? If it is not doable, I can use different driver just for this purpose (getting the list of tables), and the rest of operations, I can use CDRS.

Please advice on this.

Hi Alex,

I actually found the Select statement which can retrieve the list of tables in Older Cassandra versions :

let describe_struct_cql = "select  columnfamily_name  from system.schema_columnfamilies  where keyspace_name = 'autopush';";

It worked with me.

Hi @MaenMax ,
Great!