apache/beam · error · UnsupportedOperationException
Conversion from to BigDecimal is not supported
Error message
Conversion from %s to BigDecimal is not supported
What it means
BigDecimalConverter.forSqlType looks up a BigDecimal -> Number conversion function in CONVERTER_MAP (INTEGER/BIGINT/FLOAT/DOUBLE/DECIMAL). Unsupported SqlTypeNames are not present in the map, so an UnsupportedOperationException is thrown. This is a deliberately unsupported-conversion guard, not a data error.
Solutions
- Only call forSqlType for numeric types (INT16/INT32/INT64, FLOAT, DOUBLE, DECIMAL).
- Pre-convert to a supported numeric type before calling.
- Add the desired mapping to CONVERTER_MAP if you own the code.
- Catch UnsupportedOperationException and fall back to identity/decimal handling.
Example fix
// before
SerializableFunction<BigDecimal, ? extends Number> fn = BigDecimalConverter.forSqlType(TypeName.STRING);
// after
if (field.getType().getTypeName().isNumericType()) {
fn = BigDecimalConverter.forSqlType(field.getType().getTypeName());
} Defensive patterns
Strategy: type-guard
Validate before calling
Set<TypeName> supported = Set.of(TypeName.INT16, TypeName.INT32, TypeName.INT64, TypeName.FLOAT, TypeName.DOUBLE, TypeName.DECIMAL);
if (!supported.contains(typeName)) { /* route to non-BigDecimal path */ } Type guard
boolean isDecimalConvertible(TypeName t) {
return t != null && EnumSet.of(TypeName.INT16, TypeName.INT32, TypeName.INT64, TypeName.FLOAT, TypeName.DOUBLE, TypeName.DECIMAL).contains(t);
} Try / catch
try { fn = BigDecimalConverter.forSqlType(typeName); }
catch (UnsupportedOperationException e) { fn = v -> v; /* identity or decimal passthrough */ } Prevention
- Only call forSqlType for numeric TypeNames
- Keep a whitelist of convertible types near the call site
- Update CONVERTER_MAP when adding new Beam TypeNames
When it happens
Trigger: Calling BigDecimalConverter.forSqlType(TypeName) with a type absent from CONVERTER_MAP, e.g. TypeName.STRING, TypeName.BOOLEAN, TypeName.TIMESTAMP, or null.
Common situations: Generic code that maps arbitrary schema field types to a BigDecimal-based representation, or a new Beam TypeName added later that the converter was never extended for.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- ALTER is not supported for table
- Does not support BeamIOSinkRel in toRowList.
- Does not support queries with LIMIT in toRowList.
- Does not support
- RexNode not supported:
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/0b2a549e8eaa2b1d.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/utils/BigDecimalConverter.java:46
* TypeName}.
*/
public class BigDecimalConverter {
private static final Map<TypeName, SerializableFunction<BigDecimal, ? extends Number>>
CONVERTER_MAP =
ImmutableMap.<TypeName, SerializableFunction<BigDecimal, ? extends Number>>builder()
.put(TypeName.INT32, BigDecimal::intValue)
.put(TypeName.INT16, BigDecimal::shortValue)
.put(TypeName.BYTE, BigDecimal::byteValue)
.put(TypeName.INT64, BigDecimal::longValue)
.put(TypeName.FLOAT, BigDecimal::floatValue)
.put(TypeName.DOUBLE, BigDecimal::doubleValue)
.put(TypeName.DECIMAL, v -> v)
.build();
public static SerializableFunction<BigDecimal, ? extends Number> forSqlType(TypeName typeName) {
if (!CONVERTER_MAP.containsKey(typeName)) {
throw new UnsupportedOperationException(
"Conversion from " + typeName + " to BigDecimal is not supported");
}
return CONVERTER_MAP.get(typeName);
}
}
View on GitHub (pinned to 12126d8942)