{"record":{"id":"737e6c3d8d70c9f7","repo":"apache/seatunnel","slug":"decimal-type-should-assign-precision-and-scale-inf","errorCode":null,"errorMessage":"Decimal type should assign precision and scale information","messagePattern":"Decimal type should assign precision and scale information","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"seatunnel-api/src/main/java/org/apache/seatunnel/api/table/catalog/SeaTunnelDataTypeConvertorUtil.java","lineNumber":247,"sourceCode":"            case FLOAT:\n                return ArrayType.FLOAT_ARRAY_TYPE;\n            case DOUBLE:\n                return ArrayType.DOUBLE_ARRAY_TYPE;\n            case MAP:\n                MapType<?, ?> mapType = (MapType<?, ?>) dataType;\n                return new ArrayType<>(MapType.class, mapType);\n            case ARRAY:\n                ArrayType<?, ?> arrayType = (ArrayType<?, ?>) dataType;\n                return ArrayType.of(arrayType);\n            default:\n                throw CommonError.unsupportedDataType(\"SeaTunnel\", genericType, field);\n        }\n    }\n\n    private static SeaTunnelDataType<?> parseDecimalType(String columnStr) {\n        String[] decimalInfos = columnStr.split(\",\");\n        if (decimalInfos.length < 2) {\n            throw new RuntimeException(\n                    \"Decimal type should assign precision and scale information\");\n        }\n        int precision = Integer.parseInt(decimalInfos[0].replaceAll(\"\\\\D\", \"\"));\n        int scale = Integer.parseInt(decimalInfos[1].replaceAll(\"\\\\D\", \"\"));\n        return new DecimalType(precision, scale);\n    }\n}\n","sourceCodeStart":229,"sourceCodeEnd":255,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/catalog/SeaTunnelDataTypeConvertorUtil.java#L229-L255","documentation":"parseDecimalType parses a DECIMAL(p,s) string fragment into a DecimalType. It throws when the string does not contain both precision and scale parts (fewer than 2 comma-separated segments), because a DecimalType is meaningless without both values. This is a schema-definition validation guard in the catalog type-conversion utility.","triggerScenarios":"Calling SeaTunnelDataTypeConvertorUtil.parseComplexDataType (or parseDecimalType) with a string like \"DECIMAL\" or \"DECIMAL(10)\" — i.e. missing the scale (or both) arguments after splitting on ','.","commonSituations":"Hand-written catalog/field type strings in configs (e.g. fields: { id: \"decimal\" }), DDL copied from systems that allow DECIMAL without precision (defaults p=10,s=0), or programmatically built type strings where arguments were dropped.","solutions":["Change the type string to include both precision and scale, e.g. \"DECIMAL(10,2)\"","If the source truly has no scale, pick defaults explicitly (e.g. DECIMAL(10,0))","If generating type strings in code, validate the decimal argument count before concatenation"],"exampleFix":"// before\n\"id\": \"DECIMAL(10)\"\n// after\n\"id\": \"DECIMAL(10,2)\"","handlingStrategy":"validation","validationCode":"String s = \"DECIMAL(10,2)\";\nString inner = s.contains(\"(\") ? s.substring(s.indexOf('(')+1, s.indexOf(')')) : \"\";\nif (inner.split(\",\").length < 2) throw new IllegalArgumentException(\"decimal needs precision and scale: \" + s);","typeGuard":null,"tryCatchPattern":"try { parse(typeStr); } catch (RuntimeException e) { throw new IllegalArgumentException(\"Invalid decimal type '\" + typeStr + \"': use DECIMAL(precision,scale)\", e); }","preventionTips":["Always write DECIMAL with both arguments: DECIMAL(p,s)","Lint user configs for bare DECIMAL/NUMERIC types","Default missing values explicitly (e.g. p=10, s=0) in config parsing"],"tags":["decimal","schema","type-parsing"],"backgroundTag":"missing-required-argument","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"}