{"record":{"id":"733ee1066afcf9e4","repo":"risingwavelabs/risingwave","slug":"unexpected-default-value-type-for-real","errorCode":null,"errorMessage":"unexpected default value type for real","messagePattern":"unexpected default value type for real","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/connector/src/source/cdc/external/mysql.rs","lineNumber":242,"sourceCode":"    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            )?)\n        }\n        ColumnDefault::CurrentTimestamp | ColumnDefault::CustomExpr(_) => {\n            bail!(\"MySQL CURRENT_TIMESTAMP and custom expression default value not supported\")\n        }\n    };\n    Ok(datum)\n}\n","sourceCodeStart":224,"sourceCodeEnd":260,"githubUrl":"https://github.com/risingwavelabs/risingwave/blob/6469eb736d691e8e9b8a419a57edd6429ca77417/src/connector/src/source/cdc/external/mysql.rs#L224-L260","documentation":"derive_default_value converts a MySQL floating-point default (ColumnDefault::Real) only into Float32, Float64, or Decimal. If the target column's RW DataType is anything else, the code bails with 'unexpected default value type for real'. This is a defensive check against mapping an f64 default into an incompatible column type.","triggerScenarios":"A MySQL column with a real/floating default value (e.g. DEFAULT 1.5) whose mapped RW type is not Float32, Float64, or Decimal.","commonSituations":"Schema changes re-typing a float column to int/string while keeping the old default; type-mapping discrepancies between MySQL and RW (e.g. FLOAT mapped unexpectedly).","solutions":["Align the MySQL column's DEFAULT with its type (numeric default only on numeric columns).","Change the column default in MySQL to a compatible constant (e.g. integer default for an integer column).","Adjust connector type mapping so the column maps to Float32/Float64/Decimal."],"exampleFix":"// before (MySQL)\nALTER TABLE t MODIFY qty INT DEFAULT 1.5;\n// after\nALTER TABLE t MODIFY qty INT DEFAULT 1;","handlingStrategy":"validation","validationCode":"SELECT 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 COLUMN_DEFAULT LIKE '%.%'\n  AND NOT (COLUMN_TYPE LIKE 'float%' OR COLUMN_TYPE LIKE 'double%' OR COLUMN_TYPE LIKE 'decimal%');","typeGuard":"function realDefaultIsCompatible(mysqlColumnType, rwDataType) {\n  return /^(float|double|decimal)/.test(mysqlColumnType) &&\n    [\"Float32\",\"Float64\",\"Decimal\"].includes(rwDataType);\n}","tryCatchPattern":"try { await createCdcTable('t'); } catch (e) { if (String(e).includes('unexpected default value type for real')) { /* make the MySQL default a constant of the column's own type */ } else throw e; }","preventionTips":["Only put fractional literals on FLOAT/DOUBLE/DECIMAL columns","Avoid DEFAULT 1.5 on INT columns (MySQL may coerce; RW will reject)","Audit COLUMN_DEFAULT vs COLUMN_TYPE before CDC onboarding"],"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"}