pkolaczk / latte

Latency Tester for Apache Cassandra
Apache License 2.0
176 stars 19 forks source link

Support for user defined functions #57

Closed fruch closed 7 months ago

fruch commented 11 months ago

Rust driver can read/write UDTs: https://rust-driver.docs.scylladb.com/stable/data-types/udt.html

but seems that using it from latte workload is not currently possible

passing in Rune object didn't worked:

❯ latte load docker/latte/workloads/custom_d1.rn -- 172.17.0.2
info: Loading workload script /home/fruch/projects/scylla-cluster-tests/docker/latte/workloads/custom_d1.rn...
info: Connecting to ["172.17.0.2"]...
info: Connected to  running Cassandra version 3.0.8
info: Preparing...
info: Erasing data...
info: Loading data...
error: Cassandra error: Unsupported type: Object

I'm guessing some constructs needs to be expose to Rune, for building needed UDT objects

fruch commented 11 months ago

a snippet from what I've tried

pub async fn prepare(db) {
    db.load_cycle_count = 100;
    db.prepare(INSERT, `INSERT INTO ${KEYSPACE}.${TABLE}(id, channel_id, bucket, webhook) VALUES (:id, :channel_id, :bucket, :webhook)`).await?;
    db.prepare(READ, `SELECT * FROM ${KEYSPACE}.${TABLE} WHERE id = :id AND channel_id = :channel_id AND bucket = :bucket`).await?;
}

pub async fn load(db, i) {
    let message_webhook =  #{};
    message_webhook["id"] = 123;
    message_webhook["username"] = "fruch";
    db.execute_prepared(INSERT, [latte::hash(i), latte::hash(i+100), latte::hash(i+200).to_i32(), message_webhook]).await?
}