apache/iceberg · error · JsonToMapException
Unexpected type for field
Error message
Unexpected type ${type} for field ${fieldName} What it means
JsonToMapUtils.extractValue throws JsonToMapException when the requested Schema Type for a field is not one of the handled types (STRING, INTEGER, etc., or BYTES). The transform only knows how to convert JSON nodes into a fixed set of Kafka Connect types, so an unhandled type in the target map/struct schema is rejected.
Solutions
- Inspect the record's value schema and change the unsupported field's type to one supported by the transform (STRING, INT, BYTES, etc.).
- Flatten or cast the offending field upstream (e.g. with a different SMT) before applying the transform.
- Extend extractValue with a case for the needed type if you control the code.
Example fix
// before Schema fieldSchema = SchemaBuilder.map(Schema.STRING_SCHEMA, Schema.FLOAT64_SCHEMA).build(); // after — use a supported scalar type Schema fieldSchema = SchemaBuilder.string().build();
Defensive patterns
Strategy: validation
Validate before calling
// Pre-check schema fields against supported types before applying the transform
java.util.Set<org.apache.kafka.connect.data.Schema.Type> supported = java.util.Set.of(
Schema.Type.STRING, Schema.Type.INT8, Schema.Type.INT16, Schema.Type.INT32,
Schema.Type.INT64, Schema.Type.FLOAT32, Schema.Type.FLOAT64, Schema.Type.BOOLEAN, Schema.Type.BYTES);
for (Field f : record.valueSchema().fields()) {
if (!supported.contains(f.schema().type())) throw new IllegalStateException("unsupported type " + f.schema().type() + " for field " + f.name());
} Prevention
- Keep target schemas limited to scalar Connect types when using JSON-to-map transforms
- Test transforms against representative records before deploying
- Log valueSchema().type() for each field when debugging
When it happens
Trigger: Calling the JsonConverter-based transform with a target schema whose field has a Type that falls into the `default` branch of extractValue's switch — e.g. a MAP or custom logical type — while populating the struct via addToStruct or populateArray.
Common situations: Users apply the JsonToMap transform on records whose value schema contains types the converter does not support (e.g. nested map types or logical timestamp types), often after changing the target schema or upgrading the connector.
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
- record value is not a string, use StringConverter
- Cannot convert date
- Cannot convert time
- Cannot convert timestamp
- Cannot convert timestamptz
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/354092af46afce5f.
Report an issue: GitHub.
Appendix: source
Thrown at kafka-connect/kafka-connect-transforms/src/main/java/org/apache/iceberg/connect/transforms/JsonToMapUtils.java:259
obj = node.longValue();
break;
case FLOAT32:
obj = node.floatValue();
break;
case FLOAT64:
obj = node.doubleValue();
break;
case MAP:
ObjectNode mapNode = (ObjectNode) node;
Map<String, String> map = Maps.newHashMap();
populateMap(mapNode, map);
obj = map;
break;
case BYTES:
obj = extractBytes(node, fieldName);
break;
default:
throw new JsonToMapException(
String.format("Unexpected type %s for field %s", type, fieldName));
}
return obj;
}
private static Object extractBytes(JsonNode node, String fieldName) {
Object obj;
try {
if (node.isBigInteger()) {
obj = new BigDecimal(node.bigIntegerValue());
} else if (node.isBigDecimal()) {
obj = node.decimalValue();
} else {
obj = node.binaryValue();
}
} catch (Exception e) {
throw new JsonToMapException(
String.format("parsing binary value threw exception for %s", fieldName), e);View on GitHub (pinned to 86d9c8fc54)