prestodb/presto · error · PrestoException
GENERIC_INTERNAL_ERROR
GENERIC_INTERNAL_ERROR
Error message
Expected row value field count does not match type field count
What it means
MongoDB sink conversion error while writing a ROW-typed value: the number of fields in the incoming row block does not match the field count of the declared row type. This indicates a schema mismatch between the query's row type and the connector's expectation during INSERT.
Source
Thrown at presto-mongodb/src/main/java/com/facebook/presto/mongodb/MongoPageSink.java:225
Block mapBlock = block.getBlock(position);
// map type is converted into list of fixed keys document
List<Object> values = new ArrayList<>(mapBlock.getPositionCount() / 2);
for (int i = 0; i < mapBlock.getPositionCount(); i += 2) {
Map<String, Object> mapValue = new HashMap<>();
mapValue.put("key", getObjectValue(keyType, mapBlock, i));
mapValue.put("value", getObjectValue(valueType, mapBlock, i + 1));
values.add(mapValue);
}
return unmodifiableList(values);
}
if (isRowType(type)) {
Block rowBlock = block.getBlock(position);
List<Type> fieldTypes = type.getTypeParameters();
if (fieldTypes.size() != rowBlock.getPositionCount()) {
throw new PrestoException(StandardErrorCode.GENERIC_INTERNAL_ERROR, "Expected row value field count does not match type field count");
}
if (isImplicitRowType(type)) {
List<Object> rowValue = new ArrayList<>();
for (int i = 0; i < rowBlock.getPositionCount(); i++) {
Object element = getObjectValue(fieldTypes.get(i), rowBlock, i);
rowValue.add(element);
}
return unmodifiableList(rowValue);
}
Map<String, Object> rowValue = new HashMap<>();
for (int i = 0; i < rowBlock.getPositionCount(); i++) {
rowValue.put(
type.getTypeSignature().getParameters().get(i).getNamedTypeSignature().getName().orElse("field" + i),
getObjectValue(fieldTypes.get(i), rowBlock, i));
}
return unmodifiableMap(rowValue);View on GitHub (pinned to 55bb57d202)
Solutions
- Align the inserted row type field count with the target schema
- Recreate the MongoDB table definition to match the row type
- Cast the value to the exact ROW(...) shape before inserting
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at presto-mongodb/src/main/java/com/facebook/presto/mongodb/MongoPageSink.java:225 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/451d866450accbf3.
Report an issue: GitHub.