{"record":{"id":"0d717e72c0d019ee","repo":"prestodb/presto","slug":"invalid-function-argument-0d717e","errorCode":"INVALID_FUNCTION_ARGUMENT","errorMessage":"Number of split tokens is not equal to schema length. Expected %s received %s. Schema: %s, fields {%s}, delimiter %s","messagePattern":"Number of split tokens is not equal to schema length\\. Expected (.+?) received (.+?)\\. Schema: (.+?), fields (.+?), delimiter (.+?)","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-accumulo/src/main/java/com/facebook/presto/accumulo/model/Row.java","lineNumber":153,"sourceCode":"    /**\n     * Creates a new {@link Row} from the given delimited string based on the given {@link RowSchema}\n     *\n     * @param schema Row's schema\n     * @param str String to parse\n     * @param delimiter Delimiter of the string\n     * @return A new Row\n     * @throws PrestoException If the length of the split string is not equal to the length of the schema\n     * @throws PrestoException If the schema contains an unsupported type\n     */\n    public static Row fromString(RowSchema schema, String str, char delimiter)\n    {\n        Row row = new Row();\n\n        ImmutableList.Builder<String> builder = ImmutableList.builder();\n        List<String> fields = builder.addAll(Splitter.on(delimiter).split(str)).build();\n\n        if (fields.size() != schema.getLength()) {\n            throw new PrestoException(INVALID_FUNCTION_ARGUMENT, format(\"Number of split tokens is not equal to schema length. Expected %s received %s. Schema: %s, fields {%s}, delimiter %s\", schema.getLength(), fields.size(), schema, StringUtils.join(fields, \",\"), delimiter));\n        }\n\n        for (int i = 0; i < fields.size(); ++i) {\n            Type type = schema.getColumn(i).getType();\n            row.addField(valueFromString(fields.get(i), type), type);\n        }\n\n        return row;\n    }\n\n    /**\n     * Converts the given String into a Java object based on the given Presto type\n     *\n     * @param str String to convert\n     * @param type Presto Type\n     * @return Java object\n     * @throws PrestoException If the type is not supported by this function\n     */","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-accumulo/src/main/java/com/facebook/presto/accumulo/model/Row.java#L135-L171","documentation":"Row.fromString splits a delimited string with Splitter.on(delimiter) and asserts the token count equals the number of columns in the supplied RowSchema; if not, it throws INVALID_FUNCTION_ARGUMENT with expected vs received counts, the schema, fields, and delimiter. This guards against misaligned positional field deserialization.","triggerScenarios":"Calling Row.fromString(schema, str, delimiter) where the record's split token count != schema.getLength() — e.g. extra embedded delimiter characters in field values, missing trailing columns, or a wrong delimiter string passed in.","commonSituations":"Importing Accumulo rows whose String serialization was produced with a different delimiter; values containing the delimiter (commas/tabs in text); schema evolved (column added/removed) after rows were written.","solutions":["Verify the delimiter matches the one used when the row string was written","Escape or remove delimiter characters inside field values, or choose a delimiter that never appears in data","Reconcile the RowSchema with the actual data — regenerate row strings after schema changes","Pre-split and validate the record yourself, then build the Row via addField instead of fromString"],"exampleFix":"// before\nRow row = Row.fromString(schema, line, \",\");\n// after\nString safeDelim = \"\\u0001\"; // unit separator unlikely in data\nRow row = Row.fromString(schema, line, safeDelim);","handlingStrategy":"validation","validationCode":"List<String> fields = Splitter.on(delimiter).splitToList(str);\nif (fields.size() != schema.getLength()) {\n    throw new IllegalArgumentException(format(\"Expected %d fields, got %d\", schema.getLength(), fields.size()));\n}\nRow row = Row.fromString(schema, str, delimiter);","typeGuard":"static boolean isSplittableRecord(String str, RowSchema schema, String delimiter) {\n    return str != null && Splitter.on(delimiter).splitToList(str).size() == schema.getLength();\n}","tryCatchPattern":"try {\n    return Row.fromString(schema, line, delim);\n} catch (PrestoException e) {\n    if (e.getErrorCode().getCode() == StandardErrorCode.INVALID_FUNCTION_ARGUMENT.toErrorCode().getCode()) {\n        log.warn(\"Skipping malformed record: %s\", e.getMessage());\n        return null;\n    }\n    throw e;\n}","preventionTips":["Use a delimiter that cannot occur in data (e.g. \\u0001)","Escape delimiter characters during serialization","Re-validate record arity after any schema change","Prefer structured serializers over delimited strings for evolving schemas"],"tags":["presto","accumulo","parsing","delimiter","serialization"],"backgroundTag":"field-count-mismatch","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"}