apache/seatunnel · error · IllegalArgumentException
Invalid DECIMAL definition: " + decimalTypeDefinition
Error message
Invalid DECIMAL definition: " + decimalTypeDefinition
What it means
StarRocksTypeConverter.getPrecisionAndScale parses a DECIMAL type definition of the form 'DECIMAL(p,s)' by stripping the prefix, splitting on comma, and requiring exactly two parts. If the string doesn't yield exactly two parts, it throws IllegalArgumentException('Invalid DECIMAL definition: ...').
Solutions
- Fix the DECIMAL definition to StarRocks canonical form DECIMAL(precision, scale), e.g. DECIMAL(10,2)
- If it comes from save_mode_create_template, correct the template's decimal syntax
- Check the source table DDL in StarRocks (SHOW CREATE TABLE) and match it exactly
- If this is user input validation, pre-validate the decimal string before conversion
Example fix
// before String ddl = "DECIMAL(10)"; // missing scale // after String ddl = "DECIMAL(10,2)";
Defensive patterns
Strategy: validation
Validate before calling
String ct = "DECIMAL(10,2)"; assert ct.toUpperCase().matches("DECIMAL\\s*\\(\\s*\\d+\\s*,\\s*\\d+\\s*\\)"); // passes only canonical form Type guard
boolean isValidDecimalDef(String s) { return s != null && s.toUpperCase(Locale.ROOT).matches("DECIMAL\\s*\\(\\s*\\d+\\s*,\\s*\\d+\\s*\\)"); } Try / catch
try { converter.convert(td); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith("Invalid DECIMAL definition")) { /* normalize the DDL to DECIMAL(p,s) and retry */ } throw e; } Prevention
- Keep save_mode_create_template DECIMAL syntax canonical: DECIMAL(p,s)
- Compare with SHOW CREATE TABLE output when syncing schemas
- Pre-validate user-supplied DDL templates
When it happens
Trigger: Passing a malformed decimalTypeDefinition such as 'DECIMAL(10)' (missing scale), 'DECIMAL' (no parentheses), 'DECIMAL(10,2,3)', or a variant whose numeric part doesn't split into exactly two comma-separated integers.
Common situations: Custom save_mode_create_template producing non-standard DECIMAL DDL (e.g. DECIMAL without scale); table definitions written by hand or by other tools with invalid precision/syntax; case/spacing variants the parser doesn't normalize.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- Column type is empty.
- The decimal column type decimal( , ) is out of range, which…
- The decimal column type decimal( , ) is out of range, which…
- The decimal column type decimal( , ) is out of range, which…
- The decimal column type decimal( , ) is out of range, which…
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/756b6d5efc2b00d9.
Report an issue: GitHub.
Appendix: source
Thrown at seatunnel-connectors-v2/connector-starrocks/src/main/java/org/apache/seatunnel/connectors/seatunnel/starrocks/datatypes/StarRocksTypeConverter.java:492
if (columnType.contains("(") && columnType.contains(")")) {
return columnType.substring(0, columnType.indexOf("("));
}
return columnType;
}
private static int[] getPrecisionAndScale(String decimalTypeDefinition) {
// Remove the "DECIMALV3" part and the parentheses
decimalTypeDefinition = decimalTypeDefinition.toUpperCase(Locale.ROOT);
String numericPart = decimalTypeDefinition.replace("DECIMALV3(", "").replace(")", "");
numericPart = numericPart.replace("DECIMAL(", "").replace(")", "");
// Split by comma to separate precision and scale
String[] parts = numericPart.split(",");
if (parts.length != 2) {
throw new IllegalArgumentException(
"Invalid DECIMAL definition: " + decimalTypeDefinition);
}
// Parse precision and scale from the split parts
int precision = Integer.parseInt(parts[0].trim());
int scale = Integer.parseInt(parts[1].trim());
// Return an array containing precision and scale
return new int[] {precision, scale};
}
private void reconvertBuildArrayInternal(
SeaTunnelDataType elementType,
BasicTypeDefine.BasicTypeDefineBuilder<StarRocksType> builder,
String columnName) {
switch (elementType.getSqlType()) {
case BOOLEAN:
builder.columnType(SR_BOOLEAN_ARRAY);View on GitHub (pinned to cf67b549a7)