prestodb/presto · error · PrestoException

INVALID_FUNCTION_ARGUMENT

INVALID_FUNCTION_ARGUMENT

Error message

Key-value delimiter must appear exactly once in each entry. Bad input: '

What it means

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.

Source

Thrown at presto-main-base/src/main/java/com/facebook/presto/operator/scalar/SplitToMapFunction.java:75

            // then add the pair if it can be split by keyValueDelimiter
            Slice keyValuePair;
            int entryEnd = string.indexOf(entryDelimiter, entryStart);
            if (entryEnd >= 0) {
                keyValuePair = string.slice(entryStart, entryEnd - entryStart);
            }
            else {
                // The rest of the string is the last possible pair.
                keyValuePair = string.slice(entryStart, string.length() - entryStart);
            }

            int keyEnd = keyValuePair.indexOf(keyValueDelimiter);
            if (keyEnd >= 0) {
                int valueStart = keyEnd + keyValueDelimiter.length();
                Slice key = keyValuePair.slice(0, keyEnd);
                Slice value = keyValuePair.slice(valueStart, keyValuePair.length() - valueStart);

                if (value.indexOf(keyValueDelimiter) >= 0) {
                    throw new PrestoException(
                            INVALID_FUNCTION_ARGUMENT,
                            "Key-value delimiter must appear exactly once in each entry. Bad input: '" + keyValuePair.toStringUtf8() + "'");
                }

                if (map.containsKey(key)) {
                    if (!function.isPresent()) {
                        throw new PrestoException(
                                INVALID_FUNCTION_ARGUMENT,
                                format("Duplicate keys (%s) are not allowed. Specifying a lambda to resolve conflicts can avoid this error", key.toStringUtf8()));
                    }

                    value = function.get().apply(key, map.get(key), value);
                }

                map.put(key, value);
            }
            else {
                throw new PrestoException(

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Choose delimiters that cannot occur in the data (e.g. '\u0001' control characters) or escape values before joining.
  2. Pre-split values or strip/replace extra delimiters: replace or regexp_extract to fix entries.
  3. Use try_split_to_map? (if available) or wrap the call in try() to return NULL for malformed entries.
  4. Sanitize the source string with regexp_replace to remove duplicate delimiters before splitting.

Example fix

-- before
SELECT split_to_map('a=1=2,b=3', '=', ',');
-- after
SELECT split_to_map(replace('a=1=2,b=3', '1=2', '1-2'), '=', ',');
Defensive patterns

Strategy: validation

Validate before calling

SELECT split_to_map(regexp_replace(s, '([^^])=(?=[^,]*=)', '$1-'), '=', ',') -- neutralize extra '=' before splitting

Try / catch

SELECT try(split_to_map(s, '=', ',')) AS m;

When it happens

Trigger: Calling split_to_map('a=1=2', '=', ',') — a pair like 'a=1=2' contains '=' twice; also unescaped delimiter characters appearing inside values.

Common situations: 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.

Related errors


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/e6398b714ea58d0f. Report an issue: GitHub.