apache/seatunnel · error · RuntimeException

Decimal type should assign precision and scale information

Error message

Decimal type should assign precision and scale information

What it means

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.

Source

Thrown at seatunnel-api/src/main/java/org/apache/seatunnel/api/table/catalog/SeaTunnelDataTypeConvertorUtil.java:247

            case FLOAT:
                return ArrayType.FLOAT_ARRAY_TYPE;
            case DOUBLE:
                return ArrayType.DOUBLE_ARRAY_TYPE;
            case MAP:
                MapType<?, ?> mapType = (MapType<?, ?>) dataType;
                return new ArrayType<>(MapType.class, mapType);
            case ARRAY:
                ArrayType<?, ?> arrayType = (ArrayType<?, ?>) dataType;
                return ArrayType.of(arrayType);
            default:
                throw CommonError.unsupportedDataType("SeaTunnel", genericType, field);
        }
    }

    private static SeaTunnelDataType<?> parseDecimalType(String columnStr) {
        String[] decimalInfos = columnStr.split(",");
        if (decimalInfos.length < 2) {
            throw new RuntimeException(
                    "Decimal type should assign precision and scale information");
        }
        int precision = Integer.parseInt(decimalInfos[0].replaceAll("\\D", ""));
        int scale = Integer.parseInt(decimalInfos[1].replaceAll("\\D", ""));
        return new DecimalType(precision, scale);
    }
}

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Change the type string to include both precision and scale, e.g. "DECIMAL(10,2)"
  2. If the source truly has no scale, pick defaults explicitly (e.g. DECIMAL(10,0))
  3. If generating type strings in code, validate the decimal argument count before concatenation

Example fix

// before
"id": "DECIMAL(10)"
// after
"id": "DECIMAL(10,2)"
Defensive patterns

Strategy: validation

Validate before calling

String s = "DECIMAL(10,2)";
String inner = s.contains("(") ? s.substring(s.indexOf('(')+1, s.indexOf(')')) : "";
if (inner.split(",").length < 2) throw new IllegalArgumentException("decimal needs precision and scale: " + s);

Try / catch

try { parse(typeStr); } catch (RuntimeException e) { throw new IllegalArgumentException("Invalid decimal type '" + typeStr + "': use DECIMAL(precision,scale)", e); }

Prevention

When it happens

Trigger: Calling SeaTunnelDataTypeConvertorUtil.parseComplexDataType (or parseDecimalType) with a string like "DECIMAL" or "DECIMAL(10)" — i.e. missing the scale (or both) arguments after splitting on ','.

Common situations: 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.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/737e6c3d8d70c9f7. Report an issue: GitHub.