{"record":{"id":"27c53ee6cef817a8","repo":"apache/seatunnel","slug":"invalid-decimal-definition-decimaltypedefinition","errorCode":null,"errorMessage":"Invalid DECIMAL definition: {decimalTypeDefinition}","messagePattern":"Invalid DECIMAL definition: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-doris/src/main/java/org/apache/seatunnel/connectors/doris/datatype/AbstractDorisTypeConverter.java","lineNumber":486,"sourceCode":"                builder.dataType(DORIS_DATETIMEV2_ARRAY);\n                break;\n            default:\n                throw CommonError.convertToConnectorTypeError(\n                        IDENTIFIER, elementType.getSqlType().name(), columnName);\n        }\n    }\n\n    protected static int[] getPrecisionAndScale(String decimalTypeDefinition) {\n        // Remove the \"DECIMALV3\" part and the parentheses\n        decimalTypeDefinition = decimalTypeDefinition.toUpperCase(Locale.ROOT);\n        String numericPart = decimalTypeDefinition.replace(\"DECIMALV3(\", \"\").replace(\")\", \"\");\n        numericPart = numericPart.replace(\"DECIMAL(\", \"\").replace(\")\", \"\");\n\n        // Split by comma to separate precision and scale\n        String[] parts = numericPart.split(\",\");\n\n        if (parts.length != 2) {\n            throw new IllegalArgumentException(\n                    \"Invalid DECIMAL definition: \" + decimalTypeDefinition);\n        }\n\n        // Parse precision and scale from the split parts\n        int precision = Integer.parseInt(parts[0].trim());\n        int scale = Integer.parseInt(parts[1].trim());\n\n        // Return an array containing precision and scale\n        return new int[] {precision, scale};\n    }\n}\n","sourceCodeStart":468,"sourceCodeEnd":498,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-doris/src/main/java/org/apache/seatunnel/connectors/doris/datatype/AbstractDorisTypeConverter.java#L468-L498","documentation":"AbstractDorisTypeConverter.getPrecisionAndScale parses strings like `DECIMAL(p,s)` by stripping the wrapper and splitting on a comma; if the result does not have exactly 2 parts it throws IllegalArgumentException with the offending definition. It means the DECIMAL type string did not match the expected `DECIMAL(precision,scale)` shape.","triggerScenarios":"Passing a type string such as \"DECIMAL\", \"DECIMAL(10)\", \"DECIMALV3(10,2)\" (if the prefix strip doesn't match), or \"decimal(p, s) extra\" into precisionAndScale/getPrecisionAndScale.","commonSituations":"Mapping Doris DECIMAL(P) (scale omitted) or unparameterized DECIMAL into SeaTunnel types; upstream schema metadata returning DECIMAL variants (DECIMALV2/V3) not normalized before parsing.","solutions":["Normalize the type string to the exact `DECIMAL(p,s)` form (with both precision and scale) before conversion","Handle scale-less DECIMAL(P) by defaulting scale (commonly 0) before calling the converter","Add handling for DECIMALV2/DECIMALV3 prefixes in the converter's strip step"],"exampleFix":"// before\nconverter.precisionAndScale(\"DECIMAL(10)\");\n// after\nString def = \"DECIMAL(10)\";\nif (!def.matches(\"(?i)DECIMAL\\\\s*\\\\(\\\\s*\\\\d+\\\\s*,\\\\s*\\\\d+\\\\s*\\\\)\")) def = def.replaceFirst(\"(?i)DECIMAL\\\\s*\\\\(\\\\s*(\\\\d+)\\\\s*\\\\)\", \"DECIMAL($1,0)\");\nconverter.precisionAndScale(def); // DECIMAL(10,0)","handlingStrategy":"validation","validationCode":"// validate DECIMAL string before conversion\nif (!typeStr.matches(\"(?i)DECIMAL\\\\s*\\\\(\\\\s*\\\\d+\\\\s*,\\\\s*\\\\d+\\\\s*\\\\)\")) {\n    throw new IllegalArgumentException(\"DECIMAL must be DECIMAL(p,s), got: \" + typeStr);\n}","typeGuard":"boolean isParameterizedDecimal(String t) {\n    return t != null && t.matches(\"(?i)DECIMAL\\\\s*\\\\(\\\\s*\\\\d+\\\\s*,\\\\s*\\\\d+\\\\s*\\\\)\");\n}","tryCatchPattern":"try {\n    SeaTunnelDataType<?> dt = converter.precisionAndScale(typeStr);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Invalid DECIMAL definition\")) {\n        // normalize: append default scale or strip DECIMALV2/V3 prefixes, then retry\n    } else throw e;\n}","preventionTips":["Always render DECIMAL with explicit precision and scale","Normalize DECIMAL(P) to DECIMAL(P,0) before conversion","Account for DECIMALV2/DECIMALV3 variants in schema mapping code"],"tags":["type-conversion","doris","decimal"],"backgroundTag":"invalid-argument-format","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}