{"record":{"id":"9a0affed837734f8","repo":"risingwavelabs/risingwave","slug":"failed-to-lookup-type-matrix-unknown-type","errorCode":null,"errorMessage":"failed to lookup type matrix: unknown type: {}","messagePattern":"failed to lookup type matrix: unknown type: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"src/expr/macro/src/types.rs","lineNumber":87,"sourceCode":"fn lookup_matrix(mut ty: &str, idx: usize) -> &str {\n    if ty.ends_with(\"[]\") {\n        ty = \"anyarray\";\n    } else if ty.starts_with(\"struct\") {\n        ty = \"struct\";\n    } else if ty == \"void\" {\n        // XXX: we don't support void type yet.\n        //      replace it with int for now.\n        ty = \"int4\";\n    }\n    let s = TYPE_MATRIX.trim().lines().find_map(|line| {\n        let mut parts = line.split_whitespace();\n        if parts.next() == Some(ty) {\n            Some(parts.nth(idx - 1).unwrap())\n        } else {\n            None\n        }\n    });\n    s.unwrap_or_else(|| panic!(\"failed to lookup type matrix: unknown type: {}\", ty))\n}\n\n/// Expands a type wildcard string into a list of concrete types.\npub fn expand_type_wildcard(ty: &str) -> Vec<&str> {\n    match ty {\n        \"*\" => TYPE_MATRIX\n            .trim()\n            .lines()\n            .map(|l| l.split_whitespace().next().unwrap())\n            .filter(|l| *l != \"any\")\n            .collect(),\n        \"*int\" => vec![\"int2\", \"int4\", \"int8\"],\n        \"*float\" => vec![\"float4\", \"float8\"],\n        _ => vec![ty],\n    }\n}\n\n/// Computes the minimal compatible type between a pair of data types.","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/expr/macro/src/types.rs#L69-L105","documentation":"`lookup_matrix` in src/expr/macro/src/types.rs resolves type names (int4, varchar, ...) against a fixed TYPE_MATRIX table to obtain data/array/owned/ref types. Any type string that does not match a row (after `[]`→anyarray, `struct*`→struct, `void`→int4 normalization) panics with \"failed to lookup type matrix: unknown type: {}\".","triggerScenarios":"Declaring `#[function]` or `#[aggregate]` signatures using unsupported or misspelled type names such as `int`, `integer`, `text`, `string`, `float`, or a custom type not present in TYPE_MATRIX; this panic propagates through data_type/array_type/owned_type/ref_type/is_primitive.","commonSituations":"Developers writing SQL-ish names instead of the internal short names (int4 vs int, varchar vs text); using a newly introduced type before adding it to the matrix; case mismatches (`INT4`).","solutions":["Use exact matrix names: int2/int4/int8, float4/float8, varchar, bytea, boolean, decimal, date, time, timestamp, timestamptz, interval, jsonb, etc.","If the type genuinely doesn't exist, add a new row to TYPE_MATRIX in src/expr/macro/src/types.rs.","Remember `[]`, `struct<...>`, and `void` are auto-normalized; other aliases are not — normalize your string yourself if needed."],"exampleFix":"// before - `int` is not in the type matrix\n#[function(\"my_add(int, int)\")]\n\n// after\n#[function(\"my_add(int4, int4)\")]","handlingStrategy":"validation","validationCode":"const MATRIX_NAMES: &[&str] = &[\"boolean\",\"int2\",\"int4\",\"int8\",\"int256\",\"float4\",\"float8\",\"decimal\",\"serial\",\"date\",\"time\",\"timestamp\",\"timestamptz\",\"interval\",\"varchar\",\"bytea\",\"jsonb\",\"variant\",\"vector\",\"anyarray\",\"struct\",\"anymap\",\"any\"];\nfn type_known(ty: &str) -> bool {\n    let t = if ty.ends_with(\"[]\") { \"anyarray\" }\n        else if ty.starts_with(\"struct\") { \"struct\" }\n        else if ty == \"void\" { \"int4\" } else { ty };\n    MATRIX_NAMES.contains(&t)\n}\nassert!(type_known(\"int4\"));\nassert!(!type_known(\"int\"));","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use only names from TYPE_MATRIX in signature strings; `int`/`text`/`string` are NOT valid — use int4/varchar.","Note the automatic rewrites: `T[]` -> anyarray, `struct<...>` -> struct, `void` -> int4; anything else must match exactly.","When adding a new scalar type, add its row to TYPE_MATRIX in the same PR that uses it in signatures."],"tags":["proc-macro","compile-time","type-matrix","lookup"],"backgroundTag":"invalid-enum-value","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"}