{"record":{"id":"356fd71e1bf67098","repo":"risingwavelabs/risingwave","slug":"internal-error-entered-unreachable-code-356fd7","errorCode":null,"errorMessage":"internal error: entered unreachable code","messagePattern":"internal error: entered unreachable code","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/frontend/src/handler/create_function.rs","lineNumber":176,"sourceCode":"    };\n    let base64_decoded = match &params.using {\n        Some(CreateFunctionUsing::Base64(encoded)) => {\n            use base64::prelude::{BASE64_STANDARD, Engine};\n            let bytes = BASE64_STANDARD\n                .decode(encoded)\n                .context(\"invalid base64 encoding\")?;\n            Some(bytes)\n        }\n        _ => None,\n    };\n\n    let create_fn =\n        risingwave_expr::sig::find_udf_impl(&language, runtime.as_deref(), link)?.create_fn;\n    let output = create_fn(CreateOptions {\n        kind: match kind {\n            Kind::Scalar(_) => UdfKind::Scalar,\n            Kind::Table(_) => UdfKind::Table,\n            Kind::Aggregate(_) => unreachable!(),\n        },\n        name: &function_name,\n        arg_names: &arg_names,\n        arg_types: &arg_types,\n        return_type: &return_type,\n        as_: params.as_.as_ref().map(|s| s.as_str()),\n        using_link: link,\n        using_base64_decoded: base64_decoded.as_deref(),\n    })?;\n\n    let function = PbFunction {\n        id: FunctionId::placeholder(),\n        schema_id,\n        database_id,\n        name: function_name,\n        kind: Some(kind),\n        arg_names,\n        arg_types: arg_types.into_iter().map(|t| t.into()).collect(),","sourceCodeStart":158,"sourceCodeEnd":194,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/frontend/src/handler/create_function.rs#L158-L194","documentation":"When creating a UDF, the code maps the SQL function Kind to a UdfKind. Scalar and Table functions are handled; an Aggregate kind reaches unreachable!(), because aggregate UDFs are not supported for creation via this path.","triggerScenarios":"CREATE FUNCTION ... AS ... with LANGUAGE (python/javascript/rust) where the declared function kind is AGGREGATE (Kind::Aggregate), e.g. CREATE AGGREGATE-style UDF definition routed here.","commonSituations":"Users attempting to register custom aggregate functions as external UDFs, which the current UDF runtime does not support.","solutions":["Create the function as a SCALAR or TABLE UDF instead of AGGREGATE","Implement the aggregation in SQL using a regular UDF plus aggregation expressions","Check RisingWave docs/release notes for external aggregate UDF support before attempting"],"exampleFix":"-- before\nCREATE FUNCTION my_agg(...) RETURNS ... LANGUAGE python AS $$...$$ AGGREGATE;\n-- after\nCREATE FUNCTION my_scalar_fn(...) RETURNS ... LANGUAGE python AS $$...$$;","handlingStrategy":"validation","validationCode":"-- Create only scalar/table UDFs; ensure no AGGREGATE kind is declared\n-- CREATE FUNCTION ... RETURNS ... LANGUAGE python AS $$...$$  (no AGGREGATE)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never declare external UDFs as AGGREGATE","Check UDF language runtime capabilities before CREATE FUNCTION","Consult docs on supported UDF kinds"],"tags":["frontend","udf","unreachable","aggregate"],"backgroundTag":"unsupported-operation","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}