{"record":{"id":"a14fbebe4dd137a3","repo":"risingwavelabs/risingwave","slug":"pgvector-type-vector-is-missing-dimension-expec","errorCode":null,"errorMessage":"pgvector type `vector` is missing dimension, expected `vector(n)`","messagePattern":"pgvector type `vector` is missing dimension, expected `vector\\(n\\)`","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/connector/src/connector_common/postgres.rs","lineNumber":745,"sourceCode":"            if let Some(dim) = parse_pgvector_dimension(name)? {\n                DataType::Vector(dim)\n            } else if matches!(name.to_ascii_lowercase().as_str(), \"geometry\" | \"geography\") {\n                DataType::Bytea\n            } else {\n                // NOTES: user-defined enum type is classified as `Unknown`\n                tracing::warn!(\"unknown PostgreSQL data type `{name}`; mapping it to varchar\");\n                DataType::Varchar\n            }\n        }\n    };\n\n    Ok(dtype)\n}\n\nfn parse_pgvector_dimension(type_name: &str) -> ConnectorResult<Option<usize>> {\n    let normalized = type_name.trim().to_ascii_lowercase();\n    if normalized == \"vector\" {\n        bail!(\"pgvector type `vector` is missing dimension, expected `vector(n)`\")\n    }\n    if !normalized.starts_with(\"vector(\") || !normalized.ends_with(')') {\n        return Ok(None);\n    }\n\n    let dim_text = normalized\n        .trim_start_matches(\"vector(\")\n        .trim_end_matches(')')\n        .trim();\n    let dim = dim_text\n        .parse::<usize>()\n        .map_err(|_| anyhow!(\"invalid pgvector dimension in type `{type_name}`\"))?;\n\n    if !(1..=DataType::VEC_MAX_SIZE).contains(&dim) {\n        bail!(\n            \"pgvector dimension out of range in type `{}`: expect 1..={}\",\n            type_name,\n            DataType::VEC_MAX_SIZE","sourceCodeStart":727,"sourceCodeEnd":763,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/connector/src/connector_common/postgres.rs#L727-L763","documentation":"pgvector's `vector` type requires an explicit dimension in RisingWave. `parse_pgvector_dimension` bails when the normalized type name is exactly `vector` with no `(n)` suffix, because a dimension is mandatory for the RW Vector type.","triggerScenarios":"Schema discovery on a Postgres column created as `vector` (no dimension) whose type name string reaches `parse_pgvector_dimension` via `sea_type_to_rw_type`.","commonSituations":"Upstream table created with untyped pgvector column (`CREATE TABLE t (v vector);`), which Postgres allows; pgvector extension used loosely without typed columns.","solutions":["Recreate/alter the upstream column with a dimension: `ALTER TABLE t ALTER COLUMN v TYPE vector(1536);`","Re-run schema discovery in RisingWave after fixing the column type"],"exampleFix":"-- before\nCREATE TABLE embeddings (v vector);\n-- after\nCREATE TABLE embeddings (v vector(1536));","handlingStrategy":"validation","validationCode":"-- ensure the pgvector column declares a dimension\nSELECT attname, atttypmod FROM pg_attribute\nWHERE attrelid = 'public.embeddings'::regclass AND attname = 'v';\n-- a usable atttypmod implies vector(n); 0 means bare `vector`","typeGuard":"fn has_vector_dimension(type_name: &str) -> bool {\n    let n = type_name.trim().to_ascii_lowercase();\n    n.starts_with(\"vector(\") && n.ends_with(')')\n}","tryCatchPattern":"match discovery_result {\n    Err(e) if e.to_string().contains(\"missing dimension, expected `vector(n)`\") => {\n        Err(CdcError::PgVectorUndimensioned(\"ALTER TABLE ... ALTER COLUMN v TYPE vector(n)\".into()))\n    }\n    other => other,\n}","preventionTips":["Never declare pgvector columns as bare `vector`; always `vector(n)`","Add dimension checks to upstream schema linters","Document required column typing for CDC source tables"],"tags":["postgres","pgvector","vector","type-mapping"],"backgroundTag":"missing-required-argument","analyzedSha":"6469eb736d691e8e9b8a419a57edd6429ca77417","analyzedAt":"2026-09-11T21:06:21.487Z","contentChangedAt":"2026-09-11T21:06:21.487Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}