{"record":{"id":"05698a61601bb508","repo":"apache/seatunnel","slug":"the-size-of-collection-is-not-equal-to-the-size-of","errorCode":null,"errorMessage":"The size of collection is not equal to the size of row type","messagePattern":"The size of collection is not equal to the size of row type","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"seatunnel-api/src/main/java/org/apache/seatunnel/api/table/converter/BasicDataConverter.java","lineNumber":211,"sourceCode":"\n        throw new UnsupportedOperationException(\n                \"Unsupported convert \" + value.getClass() + \" to Array, typeDefine: \" + typeDefine);\n    }\n\n    default SeaTunnelRow convertRow(T typeDefine, Column columnDefine, Object value)\n            throws UnsupportedOperationException {\n        return convertRow((SeaTunnelRowType) columnDefine.getDataType(), value);\n    }\n\n    default SeaTunnelRow convertRow(SeaTunnelRowType typeDefine, Object value)\n            throws UnsupportedOperationException {\n        if (value instanceof SeaTunnelRow) {\n            return (SeaTunnelRow) value;\n        }\n        if (value instanceof Collection) {\n            Collection collection = (Collection) value;\n            if (collection.size() != typeDefine.getTotalFields()) {\n                throw new IllegalArgumentException(\n                        \"The size of collection is not equal to the size of row type\");\n            }\n\n            Object[] array = new Object[collection.size()];\n            int i = 0;\n            for (Iterator iterator = collection.iterator(); iterator.hasNext(); i++) {\n                Object object = iterator.next();\n                SeaTunnelDataType<?> type = typeDefine.getFieldType(i);\n                array[i] = convert(type, object);\n            }\n            return new SeaTunnelRow(array);\n        }\n        if (value instanceof Map) {\n            Map map = (Map) value;\n\n            Object[] array = new Object[typeDefine.getTotalFields()];\n            for (int i = 0; i < typeDefine.getTotalFields(); i++) {\n                String key = typeDefine.getFieldName(i);","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/converter/BasicDataConverter.java#L193-L229","documentation":"When convertRow receives a Collection (not already a SeaTunnelRow), it builds a SeaTunnelRow positionally from the collection's elements. This IllegalArgumentException is thrown when collection.size() does not equal typeDefine.getTotalFields(), because the fields could not be mapped one-to-one onto the row schema.","triggerScenarios":"Calling convertRow(rowType, column, value) — directly or through convert(...) with a ROW SqlType — with a List whose element count differs from the number of fields declared in the SeaTunnelRowType.","commonSituations":"Upstream added/removed a column but the declared row type was not updated; mapping a SELECT with fewer columns than the target table schema; off-by-one from including or excluding an extra value like a version or timestamp column.","solutions":["Make the collection size match the SeaTunnelRowType field count — add missing values or pad with nulls intentionally.","Update the SeaTunnelRowType (CatalogTable schema) to reflect the actual number of fields in the data.","Log/inspect the collection contents to find the extra or missing field, then fix the producing code.","If fields are misaligned rather than missing, reorder the collection to match the declared field order."],"exampleFix":"// before\nconverter.convertRow(rowType, column, Arrays.asList(\"a\", 1)); // rowType has 3 fields\n// after\nconverter.convertRow(rowType, column, Arrays.asList(\"a\", 1, null)); // pad missing field with null","handlingStrategy":"validation","validationCode":"if (value instanceof Collection) {\n    if (((Collection<?>) value).size() != rowType.getTotalFields()) {\n        throw new IllegalArgumentException(\"Collection size \" + ((Collection<?>) value).size()\n            + \" != row type fields \" + rowType.getTotalFields());\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    return converter.convertRow(rowType, column, collection);\n} catch (IllegalArgumentException e) {\n    LOG.error(\"Row arity mismatch: {}\", e.getMessage());\n    throw new IOException(\"Schema/data arity mismatch\", e);\n}","preventionTips":["Keep SeaTunnelRowType field list in sync with the producing query/record shape.","When columns are added upstream, pad the collection with nulls or update the schema in the same change.","Write a unit test asserting collection.size() == rowType.getTotalFields() for your records.","Beware extra metadata columns (timestamps, versions) sneaking into the collection."],"tags":["schema-mismatch","row-conversion","seatunnel-api"],"backgroundTag":"shape-mismatch","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}