{"record":{"id":"451d866450accbf3","repo":"prestodb/presto","slug":"generic-internal-error-451d86","errorCode":"GENERIC_INTERNAL_ERROR","errorMessage":"Expected row value field count does not match type field count","messagePattern":"Expected row value field count does not match type field count","errorType":"error_code","errorClass":"PrestoException","httpStatus":500,"severity":"error","filePath":"presto-mongodb/src/main/java/com/facebook/presto/mongodb/MongoPageSink.java","lineNumber":225,"sourceCode":"            Block mapBlock = block.getBlock(position);\n\n            // map type is converted into list of fixed keys document\n            List<Object> values = new ArrayList<>(mapBlock.getPositionCount() / 2);\n            for (int i = 0; i < mapBlock.getPositionCount(); i += 2) {\n                Map<String, Object> mapValue = new HashMap<>();\n                mapValue.put(\"key\", getObjectValue(keyType, mapBlock, i));\n                mapValue.put(\"value\", getObjectValue(valueType, mapBlock, i + 1));\n                values.add(mapValue);\n            }\n\n            return unmodifiableList(values);\n        }\n        if (isRowType(type)) {\n            Block rowBlock = block.getBlock(position);\n\n            List<Type> fieldTypes = type.getTypeParameters();\n            if (fieldTypes.size() != rowBlock.getPositionCount()) {\n                throw new PrestoException(StandardErrorCode.GENERIC_INTERNAL_ERROR, \"Expected row value field count does not match type field count\");\n            }\n\n            if (isImplicitRowType(type)) {\n                List<Object> rowValue = new ArrayList<>();\n                for (int i = 0; i < rowBlock.getPositionCount(); i++) {\n                    Object element = getObjectValue(fieldTypes.get(i), rowBlock, i);\n                    rowValue.add(element);\n                }\n                return unmodifiableList(rowValue);\n            }\n\n            Map<String, Object> rowValue = new HashMap<>();\n            for (int i = 0; i < rowBlock.getPositionCount(); i++) {\n                rowValue.put(\n                        type.getTypeSignature().getParameters().get(i).getNamedTypeSignature().getName().orElse(\"field\" + i),\n                        getObjectValue(fieldTypes.get(i), rowBlock, i));\n            }\n            return unmodifiableMap(rowValue);","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-mongodb/src/main/java/com/facebook/presto/mongodb/MongoPageSink.java#L207-L243","documentation":"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.","triggerScenarios":"Thrown at presto-mongodb/src/main/java/com/facebook/presto/mongodb/MongoPageSink.java:225 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}