I am testing out migrating some code from go to rust. It’s been mostly productive and painless, I haven’t become stuck at any point except for this one. I was wondering if someone could point me in the right direction.
We are selecting for a subset of records in certain timeblock
partitions using the mintimeuuid
, like this:
cqlsh:tt> select recorded, level, event from system_log where timeblock in (19744, 19745) and recorded < mintimeuuid(5000000000000);
recorded | level | event
--------------------------------------+-------+--------
07b7f471-ba45-11ee-af7b-6b8953004c3e | 4 | loaded
bf179401-ba44-11ee-af7b-6b8953004c3e | 4 | loaded
a6dabe81-ba44-11ee-af7b-6b8953004c3e | 4 | loaded
However, when we try to pass an i64
into mintimeuuid()
in the same way we can in clash (and in gocql
), we get an error, and I can’t work out the appropriate solution, how do we do this with the ScyllaDB driver?
Here is the error:
failed: BadQuery(SerializationError(SerializationError(BuiltinSerializationError { rust_name: “(i64, i64, i64)”, kind: ColumnSerializationFailed { name: “arg0(system.mintimeuuid)”, err: SerializationError(BuiltinTypeCheckError { rust_name: “i64”, got: Timestamp, kind: MismatchedType { expected: [BigInt] } }) } })))
Here is the code:
match c.session.query(format!("select recorded, level, ip, person, event, fields
from system_log
where timeblock in (?, ?) and recorded < mintimeuuid(?)
order by recorded desc
limit {}", limit), (now, previous, before)).await
{
Ok(q) => {
let mut items = Vec::new();
if let Some(rows) = q.rows {
for row in rows
.into_typed::<(Uuid, i8, String, String, String, Vec<LogField>)>()
{
match row {
Ok(r) => {
println!("log: {}, {}, {}, {:?}", r.0, r.1, r.2, r.3);
items.push(Log {
recorded: r.0,
level: i8_to_level(r.1),
ip: r.2,
person: r.3,
event: r.4,
fields: r.5,
});
}
Err(e) => {
println!("failed: {:?}", e);
return Err(DatabaseFailure);
}
}
}
}
return Ok(items);
}
Err(e) => {
println!("failed: {:?}", e);
return Err(errors::Error::DatabaseFailure);
}
};
}