{"record":{"id":"e6398b714ea58d0f","repo":"prestodb/presto","slug":"invalid-function-argument-e6398b","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/SplitToMapFunction.java","lineNumber":75,"sourceCode":"            // 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                int valueStart = keyEnd + keyValueDelimiter.length();\n                Slice key = keyValuePair.slice(0, keyEnd);\n                Slice value = keyValuePair.slice(valueStart, keyValuePair.length() - valueStart);\n\n                if (value.indexOf(keyValueDelimiter) >= 0) {\n                    throw new PrestoException(\n                            INVALID_FUNCTION_ARGUMENT,\n                            \"Key-value delimiter must appear exactly once in each entry. Bad input: '\" + keyValuePair.toStringUtf8() + \"'\");\n                }\n\n                if (map.containsKey(key)) {\n                    if (!function.isPresent()) {\n                        throw new PrestoException(\n                                INVALID_FUNCTION_ARGUMENT,\n                                format(\"Duplicate keys (%s) are not allowed. Specifying a lambda to resolve conflicts can avoid this error\", key.toStringUtf8()));\n                    }\n\n                    value = function.get().apply(key, map.get(key), value);\n                }\n\n                map.put(key, value);\n            }\n            else {\n                throw new PrestoException(","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/operator/scalar/SplitToMapFunction.java#L57-L93","documentation":"split_to_map splits a string into key-value pairs using an entry and a key-value delimiter. After extracting key and value, it verifies the value contains no further occurrence of the key-value delimiter; if it does, the entry has the delimiter more than once and is ambiguous, so INVALID_FUNCTION_ARGUMENT is thrown with the offending pair.","triggerScenarios":"Calling split_to_map('a=1=2', '=', ',') — a pair like 'a=1=2' contains '=' twice; also unescaped delimiter characters appearing inside values.","commonSituations":"Delimiters chosen from characters that appear in data (e.g. '=' inside base64, ':' inside URLs), user-supplied strings that are not normalized, or concatenating fields with the delimiter unescaped.","solutions":["Choose delimiters that cannot occur in the data (e.g. '\\u0001' control characters) or escape values before joining.","Pre-split values or strip/replace extra delimiters: replace or regexp_extract to fix entries.","Use try_split_to_map? (if available) or wrap the call in try() to return NULL for malformed entries.","Sanitize the source string with regexp_replace to remove duplicate delimiters before splitting."],"exampleFix":"-- before\nSELECT split_to_map('a=1=2,b=3', '=', ',');\n-- after\nSELECT split_to_map(replace('a=1=2,b=3', '1=2', '1-2'), '=', ',');","handlingStrategy":"validation","validationCode":"SELECT split_to_map(regexp_replace(s, '([^^])=(?=[^,]*=)', '$1-'), '=', ',') -- neutralize extra '=' before splitting","typeGuard":null,"tryCatchPattern":"SELECT try(split_to_map(s, '=', ',')) AS m;","preventionTips":[],"tags":["presto","sql","string-parsing","delimiter","invalid-argument"],"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"}