Splitgraph has been acquired by EDB! Read the blog post.

Custom WASM user-defined functions

Seafowl uses Wasmtime and msgpack to support creating user-defined functions (UDFs). You can write a function in any language that can produce WASM bytecode and use it to extend Seafowl as long as it complies with Seafowl's UDF protocol.

Rust example UDF repository

We provide a Rust example UDF which implements a very simple user-defined function, add_i64(). By forking the repository, this code can be used as a starting point to create more complex UDFs.

Any data type supported by Seafowl may be used for the function's input or return values. The example repository contains code for decoding and -where necessary- encoding Seafowl data types.

The WASM UDF protocol

Seafowl doesn't care which language WASM UDFs are written in, as long as:

  1. The compiled wasm module exports an alloc() function for allocating WASM linear memory by Seafowl.
  2. The compiled wasm module exports a dealloc() function for freeing previously allocated linear memory.
  3. The WASM export implementing the UDF's functionality expects to receive and returns pointers to msgpack-serialized data. Input must be an array of values, output a msgpack-encoded Seafowl data type.

Creating the function in Seafowl

Once the WASM bytecode is ready, you can now create the UDF in Seafowl by encoding it as Base64 and using the CREATE FUNCTION statement. There's no need to do it by hand, as the example UDF repository's create_udf.sh automates the process once the file has been edited to contain the correct parameters.

The SQL for registering the example UDF is:

CREATE FUNCTION add_i64 AS '
{
  "entrypoint": "add_i64",
  "language": "wasmMessagePack",
  "input_types": ["BIGINT", "BIGINT"],
  "return_type": "BIGINT",
  "data": "AGFzbQEAAAABOAtgAX8Bf2ACf38Bf2ABfwBgAn9/AGAAAGADf39/AGAAAX9gAX8BfmACf34AYAR/f39/AGABfgF/Ay0sCQQCAwMFBAIGAQEBBQADBQoBAwcAAgQDCAICBAAGAQcIAAABAAEAAAAAAgUEBQFwAQYGBQMBAAEGSw5/AEGgCAt/AUEAC38BQQALfwFBAAt/AUEAC38BQQALfwFBAAt/AUEAC38BQQALfwFBAAt/AUEAC38BQQALfwBBoBoLfwFBvJsCCwdkCgdteUFib3J0AwAFYWxsb2MADQdkZWFsbG9jAA4HYWRkX2k2NAAhBV9fbmV3AAsFX19waW4AFAdfX3VucGluABUJX19jb2xsZWN0ABYLX19ydHRpX2Jhc2UDDAZtZW1vc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AZQBkAGUAZQBlAGYAZgAwAGYAMQBmADIAZgAzAGYANABmADUAZgA2AGYANwBmADgAZgA5AGYAYQBmAGIAZgBjAGYAZABmAGUAZgBmAEH8FwsBXABBiBgLTwEAAABIAAAAMAAxADIAMwA0ADUANgA3ADgAOQBhAGIAYwBkAGUAZgBnAGgAaQBqAGsAbABtAG4AbwBwAHEAcgBzAHQAdQB2AHcAeAB5AHoAQdwYCwEsAEHoGAsfAQAAABgAAAA7ACAAdAB5AHAAZQAgAD0AIABpADYANABBjBkLATwAQZgZCysBAAAAJAAAAGIAYQBkACAAcAByAGUAZgBpAHgAIABmAG8AcgAgAGkAbgB0AEHMGQsBHABB2BkLCRIAAAAIAAAABQBB7BkLASwAQfgZCyMBAAAAHAAAAEkAbgB2AGEAbABpAGQAIABsAGUAbgBnAHQAaABBoBoLDRMAAAAgAAAAAAAAACAAQewaCxEgAAAAAAAAAAJBAAAAAAAAIABBlBsLAgIJAEGkGwsCAgoAQbAbCwEGACQQc291cmNlTWFwcGluZ1VSTBIuL3JlbGVhc2Uud2FzbS5tYXA="
}';

Calling the function

Finally, you can call the function:

SELECT add_i64(1,2) AS result;

Dropping or replacing the function

As of August 2023, Seafowl supports standard SQL syntax for `DROP FUNCTION``:

-- Individual functions
DROP FUNCTION sintau

-- Separate >1 function with comma
DROP FUNCTION foo, bar

-- IF EXISTS support
DROP FUNCTION IF EXISTS baz

As well as REPLACE:

CREATE OR REPLACE FUNCTION add_i64 AS '...'

Scalar-only limitation

  • Only user-defined scalar functions are supported. Functions which maintain state between invocations such as LAG or aggregation functions such as AVG cannot be implemented at the present time.