{"record":{"id":"c11d1039b359d46c","repo":"risingwavelabs/risingwave","slug":"unexpected-default-value-type-for-integer","errorCode":null,"errorMessage":"unexpected default value type for integer","messagePattern":"unexpected default value type for integer","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/connector/src/source/cdc/external/mysql.rs","lineNumber":234,"sourceCode":"                .iter()\n                .map(|part| part.column.to_lowercase())\n                .collect()\n        })\n        .filter(|names: &Vec<_>| !names.is_empty())\n}\n\nfn derive_default_value(default: ColumnDefault, data_type: &DataType) -> ConnectorResult<Datum> {\n    let datum = match default {\n        ColumnDefault::Null => None,\n        ColumnDefault::Int(val) => match data_type {\n            DataType::Int16 => Some(ScalarImpl::Int16(val as _)),\n            DataType::Int32 => Some(ScalarImpl::Int32(val as _)),\n            DataType::Int64 => Some(ScalarImpl::Int64(val)),\n            DataType::Varchar => {\n                // should be the Enum type which is mapped to Varchar\n                Some(ScalarImpl::from(val.to_string()))\n            }\n            _ => bail!(\"unexpected default value type for integer\"),\n        },\n        ColumnDefault::Real(val) => match data_type {\n            DataType::Float32 => Some(ScalarImpl::Float32(F32::from(val as f32))),\n            DataType::Float64 => Some(ScalarImpl::Float64(val.into())),\n            DataType::Decimal => Some(ScalarImpl::Decimal(\n                Decimal::try_from(val).context(\"failed to convert default value to decimal\")?,\n            )),\n            _ => bail!(\"unexpected default value type for real\"),\n        },\n        ColumnDefault::String(mut val) => {\n            // mysql timestamp is mapped to timestamptz, we use UTC timezone to\n            // interpret its value\n            if data_type == &DataType::Timestamptz {\n                val = timestamp_val_to_timestamptz(val.as_str())?;\n            }\n            Some(ScalarImpl::from_text(val.as_str(), data_type).map_err(|e| anyhow!(e)).context(\n                \"failed to parse mysql default value expression, only constant is supported\",\n            )?)","sourceCodeStart":216,"sourceCodeEnd":252,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/connector/src/source/cdc/external/mysql.rs#L216-L252","documentation":"derive_default_value converts a MySQL column's literal integer default into a RisingWave ScalarImpl based on the mapped RW data type. If the column's RW type is not Int32, Int64, or Varchar (e.g. the column was typed as timestamp/boolean/decimal while MySQL reported an integer default), the match falls through to bail!. This indicates a mismatch between the MySQL default value's inferred kind and the column's RW type.","triggerScenarios":"A MySQL column with an integer literal DEFAULT whose mapped RisingWave DataType is not one of Int32/Int64/Varchar — e.g. type mapping drift or a schema-change that re-typed the column.","commonSituations":"MySQL type mappings changed between versions (e.g. unsigned/serial remap) so an old default no longer matches; custom extensions treating an integer default on an unusual column type.","solutions":["Check the column's MySQL type and its DEFAULT; make the default compatible (e.g. numeric default on a numeric column).","Drop or ALTER the column default in MySQL to a supported constant.","Upgrade/align the connector type-mapping code so integer defaults map to Int32/Int64/Varchar."],"exampleFix":"// before (MySQL)\nALTER TABLE t ADD COLUMN flag BOOLEAN DEFAULT 1; -- integer default on mapped bool\n// after\nALTER TABLE t MODIFY flag BOOLEAN DEFAULT TRUE;","handlingStrategy":"validation","validationCode":"-- verify defaults match column types on MySQL\nSELECT COLUMN_NAME, COLUMN_TYPE, COLUMN_DEFAULT FROM information_schema.COLUMNS\nWHERE TABLE_SCHEMA='mydb' AND TABLE_NAME='t'\n  AND COLUMN_DEFAULT IS NOT NULL\n  AND NOT (COLUMN_TYPE LIKE 'int%' OR COLUMN_TYPE LIKE 'bigint%' OR COLUMN_TYPE LIKE 'varchar%');","typeGuard":"function integerDefaultIsCompatible(mysqlColumnType, rwDataType) {\n  return /^((tiny|small|medium|big)?int|varchar)/.test(mysqlColumnType) &&\n    [\"Int32\",\"Int64\",\"Varchar\"].includes(rwDataType);\n}","tryCatchPattern":"try { await createCdcTable('t'); } catch (e) { if (String(e).includes('unexpected default value type for integer')) { /* ALTER the MySQL column default, then retry */ } else throw e; }","preventionTips":["Keep column DEFAULT literals type-consistent with the column in MySQL","Avoid mixing integer defaults onto boolean/timestamp columns","Re-check defaults after MySQL type migrations"],"tags":["cdc","mysql","default-value","type-mismatch"],"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"}