{"record":{"id":"6abf0c37e4406acf","repo":"risingwavelabs/risingwave","slug":"postgresql-snapshot-column-name-vector-dimensi","errorCode":null,"errorMessage":"PostgreSQL snapshot column `{name}` vector dimension mismatch: expected {}, got {}","messagePattern":"PostgreSQL snapshot column `(.+?)` vector dimension mismatch: expected (.+?), got (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/connector/src/parser/postgres.rs","lineNumber":177,"sourceCode":"        DataType::Varchar | DataType::Int256 | DataType::Struct(_) => {\n            match row\n                .try_get::<_, Option<ScalarAdapter>>(i)\n                .with_context(|| format!(\"failed to decode PostgreSQL snapshot column `{name}`\"))?\n            {\n                Some(value) => value.into_scalar(data_type).map(Some).ok_or_else(|| {\n                    anyhow!(\"failed to convert PostgreSQL snapshot column `{name}` to {data_type}\")\n                }),\n                None => Ok(None),\n            }\n        }\n        DataType::Vector(expected_size) => {\n            match row\n                .try_get::<_, Option<PgVectorAdapter>>(i)\n                .with_context(|| format!(\"failed to decode PostgreSQL snapshot column `{name}`\"))?\n            {\n                Some(PgVectorAdapter(v)) => {\n                    if v.len() != *expected_size {\n                        bail!(\n                            \"PostgreSQL snapshot column `{name}` vector dimension mismatch: \\\n                             expected {}, got {}\",\n                            expected_size,\n                            v.len()\n                        );\n                    }\n                    let finite = v\n                        .into_iter()\n                        .map(Finite32::try_from)\n                        .collect::<Result<Vec<_>, _>>()\n                        .map_err(anyhow::Error::msg)\n                        .with_context(|| {\n                            format!(\n                                \"PostgreSQL snapshot column `{name}` contains a non-finite vector \\\n                                 element\"\n                            )\n                        })?;\n                    Ok(Some(ScalarImpl::Vector(VectorVal::from(finite))))","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/connector/src/parser/postgres.rs#L159-L195","documentation":"Raised when a pgvector column decoded from a PostgreSQL snapshot has a different element count than the vector dimension declared in the RisingWave column (DataType::Vector(expected_size)). The strict converter refuses to pad, truncate, or reshape, and bails with expected vs actual dimension to keep vector data faithful during CDC snapshot reads.","triggerScenarios":"`postgres_cell_to_scalar_impl_strict` processes a Vector-typed column during snapshot reads (via `postgres_row_to_owned_row_with_strict_pk`, `min_and_max`, `next_split_right_bound_exclusive`, `next_greater_bound`) and the decoded PgVectorAdapter's length differs from the RW column's declared vector size.","commonSituations":"The Postgres pgvector column was changed or created without a dimension constraint so rows contain mixed-length vectors; the RW table declares the wrong dimension; data written by older tooling with a different fixed size.","solutions":["Compare the 'got' dimension in the message against the RW column's declared dimension and fix the RW table definition (recreate/alter with the correct vector size).","Normalize data in Postgres so every row's vector has the declared length, then re-run the snapshot.","Add a dimension constraint on the Postgres side and correct offending rows.","Re-run the snapshot after fixing; the strict converter will not silently truncate."],"exampleFix":"// before: Postgres rows are 768-dim but RW declares 3\nCREATE TABLE t (emb vector(3)) FROM pg ...;\n// after\nCREATE TABLE t (emb vector(768)) FROM pg ...;","handlingStrategy":"validation","validationCode":"-- Postgres side: confirm all rows have the declared dimension\nSELECT count(*) FROM t\nWHERE cardinality(emb::text::float8[]) <> 768;","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"vector dimension mismatch\") => {\n        // parse expected/got from message, fix RW column dimension, restart snapshot\n    }\n    other => other?,\n}","preventionTips":["Declare RW vector columns with the same dimension as the Postgres vector(n) definition.","Add a CHECK/dimension constraint on the PG column to prevent mixed lengths.","Test the snapshot on a staging table before production ingestion.","Re-validate dimensions after changing the pgvector schema."],"tags":["postgres","pgvector","cdc","dimension-mismatch","snapshot"],"backgroundTag":"tensor-shape-mismatch","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"}