Skip to content

singlestore-labs/pushwasm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pushwasm

This is a command-line utility that will allows you to create a Wasm UDF in SingleStoreDB. It will transfer a Wasm module, and, optionally, a WIT file, from the local file system to the database.

Attention: The code in this repository is intended for experimental use only and is not fully tested, documented, or supported by SingleStore. Visit the SingleStore Forums to ask questions about this repository.

Compiling

Run:

cargo build --release

Usage

Push a Wasm module into SingleStoreDB.

pushwasm <COMMAND>

Commands:
  udf   Creates a Wasm User-defined function
  tvf   Creates a Wasm Table-valued function
  udaf  Creates a Wasm User-defined aggregate function
  help  Print this message or the help of the given subcommand(s)
Creates a Wasm User-defined function

Usage: pushwasm <COMMAND> [OPTIONS] --name <NAME> --wasm <WASM_SOURCE> --conn <CONNECTION>

Options:
  -n, --name <NAME>
          Name of the function

      --wasm <WASM_SOURCE>
          Wasm import

      --wit <WIT_SOURCE>
          WIT import

  -f, --force
          Force replace existing function(s)

  -p, --prompt
          Prompt for password

      --abi <ABI_TYPE>
          ABI type
          
          [default: canonical]
          [possible values: basic, canonical]

  -c, --conn <CONNECTION>
          Database connection string. Must begin with 'file://' or 'mysql://'

Examples

Create a UDF called power_of in SingleStoreDB from a Wasm module and WIT file on the local file system using a connection string on the command line.

pushwasm udf \
    -n power_of \
    --wasm work/mathfuncs.wasm \ 
    --wit work/mathfuncs.wit \
    --abi canonical \
    --conn 'mysql://username:password@dbhostname:3306/mydatabase'

Create a UDF called power_of in SingleStoreDB from a Wasm module and WIT file on the local file system using a connection string on the command line and replacing what was there previously.

pushwasm udf \
    -n power_of \
    --force \
    --wasm work/mathfuncs.wasm \ 
    --wit work/mathfuncs.wit \
    --abi canonical \
    --conn 'mysql://username:password@dbhostname:3306/mydatabase'

Create a UDF called power_of in SingleStoreDB from a Wasm module and WIT file on the local file system using a connection string in a file.

echo "mysql://username:password@dbhostname:3306/mydatabase" > /home/fred/conn-info.txt

pushwasm udf \
    -n power_of \
    --wasm work/mathfuncs.wasm \ 
    --wit work/mathfuncs.wit \
    --abi canonical \
    --conn 'file:///home/fred/conn-info.txt'

Create a UDF called power_of in SingleStoreDB from a Wasm module and WIT file on the local file system using a connection string, but entering the password interactively:

pushwasm udf \
    -n power_of \
    --wasm work/mathfuncs.wasm \ 
    --wit work/mathfuncs.wit \
    --abi canonical \
    --prompt \
    --conn 'mysql://username:password@dbhostname:3306/mydatabase'

Creates a UDAF called sum_of in SingleStoreDB from a Wasm module and WIT file, by auto-deducing the relevant functions from WIT file:

pushwasm udaf \
    -n sum_of \
    --wasm work/aggfuncs.wasm \
    --wit work/aggfuncs.wit \
    --abi canonical \
    --conn 'mysql://username:password@dbhostname:3306/mydatabase' \
    --state 'int not null' \
    --type 'int not null' \ 
    --arg 'int not null'

Creates a UDAF called sum_of in SingleStoreDB from a Wasm module and WIT file using HANDLE state & by manually specifying the member functions:

pushwasm udaf \
    -n sum_of \
    --wasm work/aggfuncs.wasm \
    --wit work/aggfuncs.wit \
    --abi canonical \
    --conn 'mysql://username:password@dbhostname:3306/mydatabase' \
    --state handle \
    --type 'int not null' \ 
    --arg 'int not null' \
    --init handle_init \ 
    --iter handle_add \ 
    --merge handle_merge \ 
    --terminate handle_get \ 
    --serialize handle_serialize \
     --deserialize handle_deserialize

About SingleStoreDB

Sign up for a free SingleStore license. This allows you to run up to 4 nodes up to 32 gigs each for free. Grab your license key from SingleStore portal and set it as an environment variable.

export SINGLESTORE_LICENSE="singlestore license"

Resources

About

Utility to push a Wasm UDF into SingleStoreDB

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages