{"record":{"id":"37977dd4472c5dea","repo":"prestodb/presto","slug":"invalid-function-argument-37977d","errorCode":"INVALID_FUNCTION_ARGUMENT","errorMessage":"Key-value delimiter must appear exactly once in each entry. Bad input: ","messagePattern":"Key-value delimiter must appear exactly once in each entry\\. Bad input: ","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/operator/scalar/SplitToMultimapFunction.java","lineNumber":71,"sourceCode":"\n        Multimap<Slice, Slice> multimap = ArrayListMultimap.create();\n        int entryStart = 0;\n        while (entryStart < string.length()) {\n            // Extract key-value pair based on current index\n            // then add the pair if it can be split by keyValueDelimiter\n            Slice keyValuePair;\n            int entryEnd = string.indexOf(entryDelimiter, entryStart);\n            if (entryEnd >= 0) {\n                keyValuePair = string.slice(entryStart, entryEnd - entryStart);\n            }\n            else {\n                // The rest of the string is the last possible pair.\n                keyValuePair = string.slice(entryStart, string.length() - entryStart);\n            }\n\n            int keyEnd = keyValuePair.indexOf(keyValueDelimiter);\n            if (keyEnd < 0) {\n                throw new PrestoException(INVALID_FUNCTION_ARGUMENT, \"Key-value delimiter must appear exactly once in each entry. Bad input: \" + keyValuePair.toStringUtf8());\n            }\n\n            int valueStart = keyEnd + keyValueDelimiter.length();\n            Slice key = keyValuePair.slice(0, keyEnd);\n            Slice value = keyValuePair.slice(valueStart, keyValuePair.length() - valueStart);\n            if (value.indexOf(keyValueDelimiter) >= 0) {\n                throw new PrestoException(INVALID_FUNCTION_ARGUMENT, \"Key-value delimiter must appear exactly once in each entry. Bad input: \" + keyValuePair.toStringUtf8());\n            }\n\n            multimap.put(key, value);\n\n            if (entryEnd < 0) {\n                // No more pairs to add\n                break;\n            }\n            // Next possible pair is placed next to the current entryDelimiter\n            entryStart = entryEnd + entryDelimiter.length();\n        }","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/operator/scalar/SplitToMultimapFunction.java#L53-L89","documentation":"split_to_multimap (like split_to_map but producing a multimap) requires each entry to contain the key-value delimiter at least once. When indexOf(keyValueDelimiter) < 0 for a pair, the entry cannot be decomposed into key and value, so INVALID_FUNCTION_ARGUMENT is thrown with the bad pair.","triggerScenarios":"split_to_multimap('a=1,b', '=', ',') — entry 'b' has no '='; empty entries produced by trailing delimiters; wrong key-value delimiter passed.","commonSituations":"Malformed 'k=v' lists from configs or URLs (bare tokens, trailing separators), delimiter mismatch after data format change.","solutions":["Ensure every entry contains the key-value delimiter; clean input first (remove empty/bare tokens).","Use the correct delimiter for the data format.","Wrap the call in try() to degrade to NULL on malformed entries.","Pre-split manually (split → unnest → filter entries containing '=' → rebuild) to skip bad pairs."],"exampleFix":"-- before\nSELECT split_to_multimap('a=1,b', '=', ',');\n-- after\nSELECT split_to_multimap('a=1,b=2', '=', ',');","handlingStrategy":"validation","validationCode":"SELECT split_to_multimap(array_join(filter(split(s, ','), e -> contains(e, '=')), ','), '=', ',')","typeGuard":null,"tryCatchPattern":"SELECT try(split_to_multimap(s, '=', ',')) AS mm;","preventionTips":[],"tags":["presto","sql","string-parsing","delimiter","multimap"],"backgroundTag":"string-delimiter-parsing-error","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"}