Skip to content

feat(sql): add WebAssembly (WASM) scalar UDF support (#1653) - #2557

Open
properSkux wants to merge 1 commit into
getdozer:mainfrom
properSkux:feat/issue-1653-wasm-udf-support
Open

properSkux wants to merge 1 commit into
getdozer:mainfrom
properSkux:feat/issue-1653-wasm-udf-support

Conversation

@properSkux

Copy link
Copy Markdown

Summary

Implements WebAssembly (WASM / AssemblyScript) User Defined Function (UDF) support in Dozer SQL (#1653):

  1. Configuration (dozer-types/src/models/udf_config.rs):

    • Adds UdfType::Wasm(WasmConfig) supporting both module: and path: YAML keys, resolving .wasm files directly or with an automatic .wasm extension fallback (e.g. udfs/wasm/my_function -> udfs/wasm/my_function.wasm).
  2. WASM Runtime & Expression Integration (dozer-sql/expression/src/wasm/):

    • Compiles and instantiates .wasm modules via wasmi behind the wasm Cargo feature flag (propagated through dozer-sql-expression, dozer-sql, and dozer-cli).
    • Registers AssemblyScript's env.abort host import so compiled AssemblyScript modules instantiate cleanly without extra glue code.
    • Validates exported function parameter count and types (i32, i64, f32, f64) against the SQL Schema at query planning time, infers return FieldType (Int / Float) and nullability, and propagates SQL NULL values during record evaluation.
  3. Tests:

    • Added YAML configuration deserialization tests in dozer-types/src/tests/udf_yaml_deserialize.rs.
    • Added WASM UDF execution and NULL propagation unit tests in dozer-sql/expression/src/wasm/mod.rs.

Fixes #1653
/claim #1653

- Add `UdfType::Wasm(WasmConfig)` to `dozer-types::models::udf_config` with `module` / `path` deserialization
- Implement `dozer-sql-expression::wasm` module using `wasmi` with AssemblyScript `env.abort` support, signature & argument type validation, and SQL `NULL` propagation
- Wire `Expression::WasmUdf` into `ExpressionBuilder::parse_sql_function` and `Expression::evaluate` behind the optional `wasm` feature across `dozer-sql-expression`, `dozer-sql`, and `dozer-cli`
- Add unit tests for YAML config deserialization and WASM UDF evaluation

Fixes getdozer#1653

Signed-off-by: Lucas Oliveira <kalopsia3445@gmail.com>
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@properSkux properSkux mentioned this pull request Nov 7, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WASM UDF support

2 participants