apache/seatunnel · error · UnsupportedOperationException
Unsupported convert to Short
Error message
Unsupported convert ${value.getClass()} to Short What it means
Thrown by BasicDataConverter.convertShort(Object value) when the value is neither a Number nor a String. It is the typeDefine-less variant of error 106, and the message reports the unexpected class that could not be narrowed to a short.
Solutions
- Pre-convert the value (parse String, box Boolean to 0/1, decode byte[]) before calling convertShort
- Update the catalog type to match the real data type
- Override convertShort(Object) in a custom converter to handle the missing branch
Example fix
// before short s = converter.convertShort(row.getField(0)); // Boolean throws // after Object v = row.getField(0); short s = (v instanceof Boolean) ? ((Boolean) v ? (short) 1 : (short) 0) : converter.convertShort(v);
Defensive patterns
Strategy: type-guard
Validate before calling
Object v = row.getField(0);
if (!(v instanceof Number) && !(v instanceof String)) {
throw new IllegalArgumentException("Value " + v.getClass() + " cannot be converted to short");
} Type guard
static boolean isShortConvertible(Object v) {
return v instanceof Number || v instanceof String;
} Try / catch
try {
s = converter.convertShort(value);
} catch (UnsupportedOperationException e) {
LOG.warn("Cannot convert {} to short", value.getClass());
s = 0;
} Prevention
- Convert booleans/enums to numeric codes upstream
- Prefer explicit casts over default coercion for SMALLINT columns
- Test with representative source records covering all field types
When it happens
Trigger: Calling the convertShort(Object) overload with Boolean, byte[], LocalDate or arbitrary objects while expecting a SMALLINT value.
Common situations: Direct use of the convenience overload in custom code; untyped Object rows from generic deserializers; schema drift between source field types and sink SMALLINT columns.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- Unsupported convert to Boolean, typeDefine
- Unsupported convert to Boolean
- Unsupported convert to Byte
- Unsupported convert to Byte, typeDefine
- Unsupported convert to Float, typeDefine
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/4258db7f66c0e76b.
Report an issue: GitHub.
Appendix: source
Thrown at seatunnel-api/src/main/java/org/apache/seatunnel/api/table/converter/BasicDataConverter.java:1213
default short convertShort(T typeDefine, Number value) {
return convertShort(value);
}
default short convertShort(T typeDefine, String value) {
return convertShort(value);
}
default short convertShort(Object value) throws UnsupportedOperationException {
if (value instanceof Short) {
return (short) value;
}
if (value instanceof Number) {
return convertShort((Number) value);
}
if (value instanceof String) {
return convertShort((String) value);
}
throw new UnsupportedOperationException(
"Unsupported convert " + value.getClass() + " to Short");
}
default short convertShort(Number value) {
return value.shortValue();
}
default short convertShort(String value) {
return Short.parseShort(value);
}
default byte convertByte(T typeDefine, Object value) throws UnsupportedOperationException {
if (value instanceof Byte) {
return (byte) value;
}
if (value instanceof Number) {
return convertByte(typeDefine, (Number) value);
}View on GitHub (pinned to cf67b549a7)