{"record":{"id":"84a53397a76fa05a","repo":"risingwavelabs/risingwave","slug":"unsupported-primary-key-data-type","errorCode":null,"errorMessage":"unsupported primary key data type: {}","messagePattern":"unsupported primary key data type: (.+?)","errorType":"validation","errorClass":"ConnectorError","httpStatus":null,"severity":"error","filePath":"src/connector/src/source/cdc/external/mysql.rs","lineNumber":759,"sourceCode":"                                    Value::from(int64_val)\n                                }\n                            }\n                            DataType::Float32 => Value::from(value.into_float32().into_inner()),\n                            DataType::Float64 => Value::from(value.into_float64().into_inner()),\n                            DataType::Varchar => Value::from(String::from(value.into_utf8())),\n                            DataType::Date => Value::from(value.into_date().0),\n                            DataType::Time => Value::from(value.into_time().0),\n                            DataType::Timestamp => Value::from(value.into_timestamp().0),\n                            DataType::Decimal => Value::from(value.into_decimal().to_string()),\n                            DataType::Timestamptz => {\n                                // Convert timestamptz to NaiveDateTime for MySQL TIMESTAMP comparison\n                                // MySQL expects NaiveDateTime for TIMESTAMP parameters\n                                let ts = value.into_timestamptz();\n                                let datetime_utc = ts.to_datetime_utc();\n                                let naive_datetime = datetime_utc.naive_utc();\n                                Value::from(naive_datetime)\n                            }\n                            _ => bail!(\"unsupported primary key data type: {}\", ty),\n                        };\n                        ConnectorResult::Ok((pk.to_lowercase(), val))\n                    } else {\n                        bail!(\"primary key {} cannot be null\", pk);\n                    }\n                })\n                .try_collect::<_, _, ConnectorError>()?;\n\n            tracing::debug!(\"snapshot read params: {:?}\", &params);\n            let rs_stream = sql\n                .with(Params::from(params))\n                .stream::<mysql_async::Row, _>(&mut conn)\n                .await?;\n\n            let row_stream = rs_stream.map(|row| {\n                // convert mysql row into OwnedRow\n                let mut row = row?;\n                mysql_row_to_owned_row_with_strict_pk(&mut row, &self.rw_schema, &self.pk_indices)","sourceCodeStart":741,"sourceCodeEnd":777,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/connector/src/source/cdc/external/mysql.rs#L741-L777","documentation":"When performing a snapshot read, the connector must convert the previous primary-key value (sentinel row) into a MySQL query parameter. The match on the upstream column type has no arm for that type, so it bails with 'unsupported primary key data type'. It signals the table's PK uses a data type this CDC connector does not yet support for key-range pagination.","triggerScenarios":"`snapshot_read_inner` (called from `snapshot_read`) reaches the `_ =>` arm of the PK value conversion match — i.e. the previous PK value is non-null but its MySQL type is not one of the explicitly handled numeric/string/timestamp types.","commonSituations":"Tables with exotic PK types (BLOB, JSON, BIT, ENUM, SET, large DECIMAL) used as primary keys; using a generated or binary column as PK in MySQL; schema drift changing a PK column's type to an unsupported one.","solutions":["Change the upstream table's primary key to a supported type (INT, BIGINT, VARCHAR, TIMESTAMP, etc.).","If you control the schema, add a surrogate auto-increment integer PK and keep the exotic column as a unique key.","Create the RisingWave CDC table on a table with a conventional PK type.","Extend the match in `snapshot_read_inner` to support the missing MySQL type if you maintain the connector."],"exampleFix":"// before: exotic JSON primary key in MySQL\nCREATE TABLE events (payload JSON PRIMARY KEY, ...);\n// after: surrogate integer PK, JSON as unique key\nCREATE TABLE events (id BIGINT AUTO_INCREMENT PRIMARY KEY, payload JSON, UNIQUE KEY (payload));","handlingStrategy":"validation","validationCode":"// Check the upstream PK column type is supported before enabling CDC\nSELECT COLUMN_NAME, DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS\n WHERE TABLE_SCHEMA = ? AND TABLE_NAME = ? AND COLUMN_KEY = 'PRI';\n-- DATA_TYPE must be one of: int, bigint, smallint, varchar, char, timestamp, date","typeGuard":null,"tryCatchPattern":"match snapshot_read(...).await {\n    Err(e) if e.to_string().contains(\"unsupported primary key data type\") => {\n        // fail fast and surface a schema-fix hint to the operator\n    },\n    r => r?,\n}","preventionTips":["Use conventional integer or string primary keys on CDC-enabled MySQL tables.","Add a surrogate auto-increment PK when a JSON/BLOB key is otherwise required.","Review table DDL before enabling CDC on legacy schemas."],"tags":["cdc","mysql","unsupported-type","primary-key"],"backgroundTag":"unsupported-operation","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"}