{"record":{"id":"f454277b6036ab28","repo":"risingwavelabs/risingwave","slug":"failed-to-convert-postgresql-snapshot-column-nam","errorCode":null,"errorMessage":"failed to convert PostgreSQL snapshot column `{name}` to {data_type}","messagePattern":"failed to convert PostgreSQL snapshot column `(.+?)` to (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/connector/src/parser/postgres.rs","lineNumber":165,"sourceCode":"        | DataType::Timestamptz\n        | DataType::Jsonb\n        | DataType::Interval\n        | DataType::Bytea => {\n            // ScalarAdapter is also fine. But ScalarImpl is more efficient\n            row.try_get::<_, Option<ScalarImpl>>(i)\n                .with_context(|| format!(\"failed to decode PostgreSQL snapshot column `{name}`\"))\n        }\n        DataType::Decimal => {\n            // Decimal is more efficient than PgNumeric in ScalarAdapter\n            try_handle_data_type!(row, i, name, Decimal)\n        }\n        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                    }","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/connector/src/parser/postgres.rs#L147-L183","documentation":"Raised in the strict PostgreSQL snapshot cell converter when a decoded Postgres value (Varchar, Int256, or Struct branch) cannot be converted into the target RisingWave scalar type. The wire value was read from Postgres but the adapter's `into_scalar` returned None for the requested data type. It is a snapshot-read-time type incompatibility between the upstream column and the RW schema.","triggerScenarios":"`postgres_cell_to_scalar_impl_strict` is called per cell during Postgres CDC snapshot reads (via `postgres_row_to_owned_row_with_strict_pk` and split-bound helpers `min_and_max`, `next_split_right_bound_exclusive`, `next_greater_bound`). Fires when the ScalarAdapter value decoded from a Varchar/Int256/Struct-typed column cannot map to that exact target DataType, e.g. a struct whose field types do not match the RW STRUCT definition.","commonSituations":"Schema drift between the RW table definition and the actual Postgres table (column type altered after table creation); an RW STRUCT whose fields do not match the Postgres composite type; a Postgres domain/custom type surfaced as a string in a column declared as Int256 or Struct.","solutions":["Check the RW table schema and align the column's declared data type with the actual Postgres column type.","Re-create or ALTER the RW external table/sink so the column type matches what Postgres returns.","If the value is legitimately convertible, cast the column in the snapshot read (e.g. SELECT col::text) and adjust the RW type.","Upgrade RisingWave or file an issue if the Postgres type should be supported for that target type."],"exampleFix":"// before: RW struct does not match the Postgres composite type\nCREATE TABLE t (info struct<a int, b text>) FROM pg ...;\n// after: align field types with the PG composite\nCREATE TABLE t (info struct<a bigint, b varchar>) FROM pg ...;","handlingStrategy":"validation","validationCode":"-- Verify RW column types match Postgres before creating the CDC table:\nSELECT column_name, data_type, udt_name FROM information_schema.columns\nWHERE table_name = 'my_table';\n-- Ensure Varchar/Int256/Struct RW types match the PG column's udt_name.","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"failed to convert PostgreSQL snapshot column\") => {\n        // halt ingestion, alert on schema mismatch\n    }\n    other => other?,\n}","preventionTips":["Diff RW table schema against Postgres information_schema before starting the snapshot.","Avoid custom/composite PG types in columns mapped to Int256 or Struct unless field types match exactly.","Re-check schemas after any Postgres ALTER TABLE.","Pin column casts in the source query for non-standard types."],"tags":["postgres","cdc","type-conversion","snapshot"],"backgroundTag":"type-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"}