Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

splitgraph/seafowl-udf-go

Repository files navigation

Seafowl UDF Go

A simple Seafowl UDF demo, intended to follow in the footsteps of the Rust example but implemented in Go instead.

HOWTO

Dependencies: Go, tinygo

task command
tinygo compile with wasi1 tinygo build -o seafowl-udf-go.wasm -target=wasi
tinygo compile tinygo build -o seafowl-udf-go.wasm
tests go test -v
compile (use tinygo for WASM) go build should output seafowl-udf-go, run it via ./seafowl-udf-go 1 2

How to run in Seafowl

It's basically identical to the Rust UDF docs

  1. Compile into a WASM using tinygo build -o seafowl-udf-go.wasm -target=wasi

  2. Install the module using ./create_udf.sh

  3. Run Seafowl (e.g. seafowl or the Docker image, whatever)

  4. Invoke the function using ./query_udf.sh

    You can invoke it directly via SQL, the shell script is just a convenience e.g.

    SELECT addi64(1, 2) AS RESULT

    using e.g. curl or psql

    And you should get back

    $ ./query_udf.sh
    SELECT addi64(1, 2) AS RESULT;
    HTTP/1.1 200 OK
    content-type: application/json; arrow-schema=%7B%22fields%22%3A%5B%7B%22children%22%3A%5B%5D%2C%22name%22%3A%22result%22%2C%22nullable%22%3Atrue%2C%22type%22%3A%7B%22bitWidth%22%3A64%2C%22isSigned%22%3Atrue%2C%22name%22%3A%22int%22%7D%7D%5D%2C%22metadata%22%3A%7B%7D%7D
    x-seafowl-query-time: 426
    vary: Authorization, Content-Type, Origin, X-Seafowl-Query
    transfer-encoding: chunked
    date: 2023年7月18日 06:34:14 GMT
    {"result":3}
    

Footnotes

  1. If you don't need concurrency/goroutines, the binary size can be squeezed even smaller via tinygo build -scheduler=none -o seafowl-udf-go.wasm -target=wasi

About

Example User Defined Function (UDF) for Seafowl in Go

Topics

Resources

Stars

Watchers

Forks

AltStyle によって変換されたページ (->オリジナル) /