prestodb/presto · error · IllegalStateException
Unexpected numeric value in varchar enum signature
Error message
Unexpected numeric value in varchar enum signature
What it means
parseEnumMap rejects a digit or '-' in the value position when the enum is a varchar (non-bigint) enum. Numeric enum values are only legal when the signature declares a numeric base type; a bare number as a varchar enum's value is a parse error.
Source
Thrown at presto-common/src/main/java/com/facebook/presto/common/type/TypeSignature.java:477
}
else if (state == EnumMapParsingState.IN_STR_VALUE) {
state = EnumMapParsingState.EXPECT_COMMA_OR_CLOSING_BRACKET;
}
else {
throw new IllegalStateException("Cannot parse enum signature");
}
}
else if (state == EnumMapParsingState.IN_KEY || state == EnumMapParsingState.IN_STR_VALUE) {
keyOrValue.append(c);
}
else if (c == ':' && state == EnumMapParsingState.EXPECT_COLON) {
key = keyOrValue.toString();
keyOrValue = new StringBuilder();
state = EnumMapParsingState.EXPECT_VALUE;
}
else if ((Character.isDigit(c) || c == '-') && state == EnumMapParsingState.EXPECT_VALUE) {
if (!isBigintEnum) {
throw new IllegalStateException("Unexpected numeric value in varchar enum signature");
}
state = EnumMapParsingState.IN_NUM_VALUE;
keyOrValue.append(c);
}
else if (Character.isDigit(c) && state == EnumMapParsingState.IN_NUM_VALUE) {
keyOrValue.append(c);
}
else if ((c == ',' || c == '}') && (state == EnumMapParsingState.EXPECT_COMMA_OR_CLOSING_BRACKET || state == EnumMapParsingState.IN_NUM_VALUE)) {
if (key == null) {
throw new IllegalStateException("Cannot parse enum signature");
}
map.put(key, keyOrValue.toString());
if (c == '}') {
return new EnumMapParsingData(i, typeName, map, isBigintEnum);
}
key = null;
keyOrValue = new StringBuilder();
state = EnumMapParsingState.EXPECT_KEY;View on GitHub (pinned to 55bb57d202)
Solutions
- Quote the numeric value: 'ENUM<varchar>{a: "1"}'.
- Or change the base type to a numeric one if values really are numbers: 'ENUM<bigint>{a: 1}'.
- Regenerate the signature programmatically so value style always matches the base type.
Example fix
// before
"ENUM<varchar>{a: 1}"
// after
"ENUM<varchar>{a: \"1\"}" Defensive patterns
Strategy: validation
Validate before calling
// varchar enums must quote numeric-looking values
if (!signature.contains("ENUM<bigint>")) {
// every ': ' value should start with '"' for varchar enums
if (signature.matches(".*:\\s*[-0-9].*")) {
throw new IllegalArgumentException("unquoted numeric value in varchar enum: " + signature);
}
} Type guard
static boolean varcharEnumValuesQuoted(String sig) {
if (sig == null || sig.contains("ENUM<bigint>")) return true;
return !sig.matches(".*:\\s*[-0-9].*");
} Try / catch
try {
TypeSignature.parseTypeSignature(signature);
} catch (IllegalStateException e) {
if (e.getMessage().contains("numeric value in varchar enum")) {
// quote the values or switch base type to bigint
} else throw e;
} Prevention
- Quote any value that could parse as a number when the enum base is varchar.
- Centralize enum-signature building so base type and value style stay consistent.
- Add unit tests covering both bigint and varchar enum round-trips.
When it happens
Trigger: Parsing 'ENUM<varchar>{a: 1}' — a quoted-key enum whose value is an unquoted number — via TypeSignature.parseTypeSignature.
Common situations: Mixing enum styles when hand-writing signatures, code generators emitting numeric values without quoting them for varchar enums, copy/paste between bigint and varchar enum definitions.
Related errors
- Unexpected varchar value in numeric enum signature
- Cannot parse enum signature
- Bad type signature: '%s'
- Cannot parse distinct type definition(%s), expected '{' afte
- Cannot parse distinct type definition(%s), expected ',' afte
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/d8e7591561bec51d.
Report an issue: GitHub.