databendlabs/databend · error
not implemented
Error message
not implemented
What it means
`create_udaf_script_function` builds the runtime for a script-based aggregate UDF. Only JavaScript (and Python behind a feature flag) are wired up; the WebAssembly branch panics with `unimplemented!`, so any attempt to register a WASM UDAF aborts the process.
Solutions
- Rewrite the aggregate function as a JavaScript script UDAF (LANGUAGE JAVASCRIPT) instead of WebAssembly
- If Python is available in your edition, deploy with the python-udf feature enabled and use LANGUAGE PYTHON
- File/track a Databend feature request for WebAssembly UDAF support
Example fix
// before CREATE AGGREGATE FUNCTION my_agg AS (x) LANGUAGE WEBASSEMBLY ...; // after CREATE AGGREGATE FUNCTION my_agg AS (x DOUBLE) RETURNS DOUBLE LANGUAGE JAVASCRIPT $$ ... $$;
Defensive patterns
Strategy: validation
Validate before calling
if (udafDef.language.toUpperCase() === "WEBASSEMBLY") {
throw new Error("WebAssembly UDAF is not implemented; use JAVASCRIPT or PYTHON");
} Type guard
function hasSupportedUdafLanguage(def) {
return ["JAVASCRIPT", "PYTHON"].includes((def.language || "").toUpperCase());
} Try / catch
try {
await createAggregateFunction(udafDef);
} catch (e) {
if (isNotImplementedPanic(e)) {
console.error(`Language ${udafDef.language} unsupported for UDAF; falling back to JAVASCRIPT`);
return createAggregateFunction({ ...udafDef, language: "JAVASCRIPT" });
}
throw e;
} Prevention
- Do not define script UDAFs with LANGUAGE WEBASSEMBLY until support lands; use JavaScript
- Verify feature flags (python-udf) before choosing PYTHON as the UDAF language
- Validate UDF definitions in CI against the set of languages your Databend build actually supports
When it happens
Trigger: Creating a script UDAF with `LANGUAGE WEBASSEMBLY` (e.g. CREATE AGGREGATE FUNCTION ... LANGUAGE WEBASSEMBLY), which routes into the UDFLanguage::WebAssembly arm of the builder in udaf_script.rs.
Common situations: Following old or aspirational docs/examples that mention WebAssembly UDFs; migrating a UDF definition written for an engine that supports WASM UDAFs to Databend.
Related errors
- internal error: entered unreachable code
- not implemented
- not implemented
- not implemented
- not implemented
AI-assisted analysis of databendlabs/databend@288d84d76e (2026-09-11).
Data as JSON: /api/errors/53b64db34802c0fe.
Report an issue: GitHub.
Appendix: source
Thrown at src/query/script_udf_support/src/udaf_script.rs:327
) -> Result<Arc<dyn AggregateFunction>> {
let UDFScriptCode { language, code, .. } = code;
let runtime = match language {
UDFLanguage::JavaScript => {
let builder = JsRuntimeBuilder {
name,
code: String::from_utf8(code.to_vec())?,
state_type: ArrowType::Struct(
state_fields
.iter()
.map(|f| f.into())
.collect::<Vec<arrow_schema::Field>>()
.into(),
),
output_type,
};
UDAFRuntime::JavaScript(JsRuntimePool::new(builder))
}
UDFLanguage::WebAssembly => unimplemented!(),
#[cfg(not(feature = "python-udf"))]
UDFLanguage::Python => {
return Err(ErrorCode::EnterpriseFeatureNotEnable(
"Failed to create python script udf",
));
}
#[cfg(feature = "python-udf")]
UDFLanguage::Python => {
let builder = python_pool::PyRuntimeBuilder {
name,
code: String::from_utf8(code.to_vec())?,
state_type: ArrowType::Struct(
state_fields
.iter()
.map(|f| f.into())
.collect::<Vec<arrow_schema::Field>>()
.into(),
),View on GitHub (pinned to 288d84d76e)