### Create Scylla Function with Wasm UDF Source: https://github.com/scylladb/scylla-rust-udf/blob/main/README.md An example CQL statement to create a ScyllaDB function using a compiled WebAssembly module. It highlights the `LANGUAGE xwasm` (or `wasm` in older versions) and how to embed the `.wat` content. ```cql CREATE FUNCTION commas(string list) CALLED ON NULL INPUT RETURNS text LANGUAGE wasm AS ' (module ...) ' ``` -------------------------------- ### Optimize and Strip Wasm Binary Source: https://github.com/scylladb/scylla-rust-udf/blob/main/README.md Demonstrates optional steps to optimize and reduce the size of the compiled WebAssembly binary using `wasm-opt` and `wasm-strip`. ```bash wasm-opt -O3 target/wasm32-wasip1/debug/my_udf_library.wasm -o target/wasm32-wasip1/debug/my_udf_library.wasm wasm-strip target/wasm32-wasip1/debug/my_udf_library.wasm ``` -------------------------------- ### Running WASM Tests with Wasmtime Source: https://github.com/scylladb/scylla-rust-udf/blob/main/README.md Provides the command to execute Rust tests for the WASM32 WASIP1 target using the Wasmtime runtime, ensuring compatibility with WASM-specific code. ```bash CARGO_TARGET_WASM32_RUNNER="wasmtime --allow-unknown-exports" cargo test --target=wasm32-wasip1 ``` -------------------------------- ### CQL to Rust Type Mappings for Tuples Source: https://github.com/scylladb/scylla-rust-udf/blob/main/README.md Shows the mapping of CQL TUPLE types to Rust tuple types, enabling the use of tuples in ScyllaDB User Defined Functions. ```rust /* CQL Type | Rust type ---------------------------------- TUPLE | (RustT1, RustT2, ...) */ ``` -------------------------------- ### Convert Wasm to WAT Source: https://github.com/scylladb/scylla-rust-udf/blob/main/README.md Converts a compiled WebAssembly binary (`.wasm`) into the WebAssembly Text format (`.wat`) using the `wasm2wat` tool. ```bash wasm2wat target/wasm32-wasip1/debug/my_udf_library.wasm > target/wasm32-wasip1/debug/my_udf_library.wat ``` -------------------------------- ### Scylla UDF CQL Type Mapping (Native Types) Source: https://github.com/scylladb/scylla-rust-udf/blob/main/README.md Provides a mapping between ScyllaDB CQL data types and their corresponding Rust types for use in User Defined Functions. ```APIDOC CQL Type Mapping: Native types: | CQL Type | Rust type | | --------- | ----------------------------- | | ASCII | String | | BIGINT | i64 | | BLOB | Vec | | BOOLEAN | bool | | COUNTER | scylla_udf::Counter | | DATE | chrono::NaiveDate | | DECIMAL | bigdecimal::Decimal | | DOUBLE | f64 | | DURATION | scylla_udf::CqlDuration | | FLOAT | f32 | | INET | std::net::IpAddr | | INT | i32 | | SMALLINT | i16 | | TEXT | String | | TIME | scylla_udf::Time | | TIMESTAMP | scylla_udf::Timestamp | | TIMEUUID | uuid::Uuid | | TINYINT | i8 | | UUID | uuid::Uuid | | VARCHAR | String | | VARINT | num_bigint::BigInt | ``` -------------------------------- ### CQL to Rust Type Mappings for Collections Source: https://github.com/scylladb/scylla-rust-udf/blob/main/README.md Illustrates how CQL collection types like LIST, MAP, and SET are mapped to their corresponding Rust types (Vec, BTreeMap, HashMap, BTreeSet, HashSet) for use in ScyllaDB User Defined Functions. ```rust /* CQL Type | Rust type ------------------------------------------------------------------------------------- LIST | Vec MAP | std::collections::BTreeMap, std::collections::HashMap SET | Vec, std::collections::BTreeSet, std::collections::HashSet */ ``` -------------------------------- ### Build Scylla UDF for Wasm Target Source: https://github.com/scylladb/scylla-rust-udf/blob/main/README.md Compiles a Rust project targeting `wasm32-wasip1` with specific RUSTFLAGS to set the stack size, a common requirement for Scylla UDFs. ```bash RUSTFLAGS="-C link-args=-zstack-size=131072" cargo build --target=wasm32-wasip1 ``` -------------------------------- ### Configure Crate Type for Scylla UDFs Source: https://github.com/scylladb/scylla-rust-udf/blob/main/README.md Configures the Rust project's `Cargo.toml` to build as a dynamic library (`cdylib`), which is required for Scylla UDFs. ```toml [lib] crate-type = ["cdylib"] ``` -------------------------------- ### Handling Nulls in Rust UDFs Source: https://github.com/scylladb/scylla-rust-udf/blob/main/README.md Explains how to handle potentially null CQL values in Rust User Defined Functions by mapping the corresponding Rust type to Option. ```rust /* If a CQL Value of type T that's mapped to type RustT may be a null (all parameter and return types in `CALLED ON NULL INPUT` UDFs), then the type used in the Rust function should be Option. */ ``` -------------------------------- ### Add Scylla UDF Dependency Source: https://github.com/scylladb/scylla-rust-udf/blob/main/README.md This snippet shows how to add the `scylla-udf` dependency to your Rust project's Cargo.toml file, which is necessary for creating Scylla UDFs. ```rust cargo add scylla-udf ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.