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

CQL Vector support #1165

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/source/data-types/data-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Database types and their Rust equivalents:
* `Map` <----> `std::collections::HashMap<K, V>`
* `Tuple` <----> Rust tuples
* `UDT (User defined type)` <----> Custom user structs with macros
* `Vector` <----> `Vec<T>`


```{eval-rst}
Expand All @@ -56,5 +57,6 @@ Database types and their Rust equivalents:
collections
tuple
udt
vector

```
26 changes: 26 additions & 0 deletions docs/source/data-types/vector.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## Vector (for Cassandra only!)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd rather skip "for Cassandra only" here. This piece of text will eventually become outdated when Scylla starts supporting the type, and nobody will remember to remove it (and you can't really remove it in released versions of the driver, I suppose).

`Vector` is represented as `Vec<T>`

```rust
# extern crate scylla;
# extern crate futures;
# use scylla::Session;
# use std::error::Error;
# async fn check_only_compiles(session: &Session) -> Result<(), Box<dyn Error>> {
use futures::TryStreamExt;

// Insert a vector of ints into the table
let my_vector: Vec<i32> = vec![1, 2, 3, 4, 5];
session
.query_unpaged("INSERT INTO keyspace.table (a) VALUES(?)", (&my_vector,))
.await?;

// Read a list of ints from the table
let mut stream = session.query_iter("SELECT a FROM keyspace.table", &[])
.await?
.rows_stream::<(Vec<i32>,)>()?;
while let Some((vector_value,)) = stream.try_next().await? {
println!("{:?}", vector);
}
# Ok(())
# }
Loading