risingwavelabs/risingwave · error

argument type mismatch, expect

Error message

argument type mismatch, expect: {:?}, actual: {:?}

What it means

When creating an external UDF, the frontend fetches the function's signature from the external UDF service and compares it with the argument types declared in `CREATE FUNCTION`. If the protobuf-declared arg types do not match the SQL-declared ones, the descriptor construction fails so the mismatch surfaces before execution.

Solutions

  1. Compare the reported `actual` (service) types with the SQL `CREATE FUNCTION ... AS ...` argument types and align them
  2. Update the CREATE FUNCTION statement to match the UDF service's registered signature
  3. Rebuild/redeploy the UDF service with the expected signature if it drifted

Example fix

-- before
CREATE FUNCTION f(INT) RETURNS INT AS 'f' USING LINK 'http://udf:8815'; -- service expects (BIGINT)
-- after
CREATE FUNCTION f(BIGINT) RETURNS INT AS 'f' USING LINK 'http://udf:8815';
Defensive patterns

Strategy: validation

Validate before calling

// compare CREATE FUNCTION arg types against the UDF service's registered signature before deploying

Try / catch

try { await rw.query(createFunctionSql) } catch (e) { if (String(e).includes('argument type mismatch')) { /* fetch /info from UDF service and align DDL */ } else throw e; }

Prevention

When it happens

Trigger: `UdfImplDescriptor::new` (via `CreateFunctionOutput`) when the external UDF server's reported `function.args` differ from the `args` given in the CREATE FUNCTION statement, as checked by `data_types_match`.

Common situations: UDF service was rebuilt with different signatures while the SQL definition was not updated; wrong order of arguments in CREATE FUNCTION; type drift (e.g. INT vs BIGINT, nullable vs not) between arrow schema and SQL types.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


AI-assisted analysis of risingwavelabs/risingwave@6469eb736d (2026-09-11). Data as JSON: /api/errors/61f2b222922673a3. Report an issue: GitHub.

Appendix: source

Thrown at src/expr/impl/src/udf/external.rs:68

            opts.arg_types
                .iter()
                .map(to_field)
                .try_collect::<Fields>()?,
        );
        let returns = arrow_schema_udf::Schema::new(if opts.kind.is_table() {
            vec![
                arrow_schema_udf::Field::new("row", arrow_schema_udf::DataType::Int32, true),
                to_field(opts.return_type)?,
            ]
        } else {
            vec![to_field(opts.return_type)?]
        });
        let function = tokio::task::block_in_place(|| {
            tokio::runtime::Handle::current().block_on(client.get(&name_in_runtime))
        })
        .context("failed to check UDF signature")?;
        if !data_types_match(&function.args, &args) {
            bail!(
                "argument type mismatch, expect: {:?}, actual: {:?}",
                args,
                function.args,
            );
        }
        if !data_types_match(&function.returns, &returns) {
            bail!(
                "return type mismatch, expect: {:?}, actual: {:?}",
                returns,
                function.returns,
            );
        }
        Ok(CreateFunctionOutput {
            name_in_runtime,
            body: None,
            compressed_binary: None,
        })
    },

View on GitHub (pinned to 6469eb736d)