{"record":{"id":"704ad4c31810a247","repo":"risingwavelabs/risingwave","slug":"column-type-mismatch","errorCode":null,"errorMessage":"Column type mismatch: {:?} != {:?}","messagePattern":"Column type mismatch: (.+?) != (.+?)","errorType":"validation","errorClass":"MetaError","httpStatus":null,"severity":"error","filePath":"src/meta/src/controller/utils.rs","lineNumber":2529,"sourceCode":"        .map(|(idx, col)| (col.column_desc.as_ref().unwrap().column_id, idx))\n        .collect::<HashMap<_, _>>();\n\n    for to_col in to {\n        let to_col = to_col.column_desc.as_ref().unwrap();\n        let to_col_type_ref = to_col.column_type.as_ref().unwrap();\n        let to_col_type = DataType::from(to_col_type_ref);\n        if let Some(from_idx) = idx_by_col_id.get(&to_col.column_id) {\n            let from_col_type = DataType::from(\n                from[*from_idx]\n                    .column_desc\n                    .as_ref()\n                    .unwrap()\n                    .column_type\n                    .as_ref()\n                    .unwrap(),\n            );\n            if !to_col_type.equals_datatype(&from_col_type) {\n                return Err(anyhow!(\n                    \"Column type mismatch: {:?} != {:?}\",\n                    from_col_type,\n                    to_col_type\n                )\n                .into());\n            }\n            exprs.push(PbExprNode {\n                function_type: expr_node::Type::Unspecified.into(),\n                return_type: Some(to_col_type_ref.clone()),\n                rex_node: Some(expr_node::RexNode::InputRef(*from_idx as _)),\n            });\n        } else {\n            let to_default_node =\n                if let Some(GeneratedOrDefaultColumn::DefaultColumn(DefaultColumnDesc {\n                    expr,\n                    ..\n                })) = &to_col.generated_or_default_column\n                {","sourceCodeStart":2511,"sourceCodeEnd":2547,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/meta/src/controller/utils.rs#L2511-L2547","documentation":"During cdc/table schema comparison the code checks each corresponding column pair's types with `equals_datatype`; on mismatch it returns \"Column type mismatch: {:?} != {:?}\" naming the source (`from`) and target (`to`) types. This enforces that schema evolution between the compared relations keeps column types identical.","triggerScenarios":"Executing the schema-compatibility path (e.g. CDC table schema sync/upsert in utils.rs) when a column exists on both sides but its DataType differs — for example VARCHAR vs INT, or differing struct field types.","commonSituations":"Upstream schema changed (ALTER TABLE at the source) while the target table was not migrated; a source connector reports a different type mapping after a version change; hand-edited or drifted table schemas in dev environments.","solutions":["Alter the target table so its column type matches the source column type shown in the error (both types are printed in order).","Recreate the downstream table/sink with the correct schema if the type cannot be altered in place.","Align connector/source type mappings (or upgrade the connector) so upstream types map to the same DataType as the target.","Compare the two `DataType` debug dumps in the message to pinpoint the differing column and update your migration scripts."],"exampleFix":"-- before: source column widened but target not migrated\n-- from: Integer, to: Varchar\nALTER TABLE t ALTER COLUMN c TYPE integer;\n-- after: target matches source type","handlingStrategy":"validation","validationCode":"fn assert_columns_compatible(from: &[Column], to: &[Column]) -> Result<(), String> {\n    for (f, t) in from.iter().zip(to) {\n        if !f.data_type.equals_datatype(&t.data_type) {\n            return Err(format!(\"column {} : {:?} != {:?}\", f.name, f.data_type, t.data_type));\n        }\n    }\n    Ok(())\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Propagate upstream ALTER TABLE changes to target tables before resuming CDC/sync","Pin connector type mappings so source types always map to the same DataType","Diff source and target schemas as a pre-flight check before enabling replication"],"tags":["meta","schema","type-mismatch","cdc"],"backgroundTag":"type-mismatch","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"}