prestodb/presto · error · IllegalStateException
Unexpected varchar value in numeric enum signature
Error message
Unexpected varchar value in numeric enum signature
What it means
parseEnumMap rejects a double-quoted (varchar) enum value encountered while the signature was declared as a numeric (BIGINT) enum. Enum signatures are either all-bigint-keyed or all-varchar-valued; mixing is invalid, so a '"' in the value position of a numeric enum is a parse failure.
Source
Thrown at presto-common/src/main/java/com/facebook/presto/common/type/TypeSignature.java:449
Map<String, String> map = new HashMap<>();
for (int i = openBracketIndex + 1; i < signature.length(); i++) {
char c = signature.charAt(i);
if (state == EnumMapParsingState.IN_KEY_ESCAPE) {
state = EnumMapParsingState.IN_KEY;
keyOrValue.append(c);
}
if (state == EnumMapParsingState.IN_STR_VALUE_ESCAPE) {
state = EnumMapParsingState.IN_STR_VALUE;
keyOrValue.append(c);
}
else if (c == '"') {
if (state == EnumMapParsingState.EXPECT_KEY) {
state = EnumMapParsingState.IN_KEY;
}
else if (state == EnumMapParsingState.EXPECT_VALUE) {
if (isBigintEnum) {
throw new IllegalStateException("Unexpected varchar value in numeric enum signature");
}
state = EnumMapParsingState.IN_STR_VALUE;
}
else if ((state == EnumMapParsingState.IN_KEY || state == EnumMapParsingState.IN_STR_VALUE)
&& i + 1 < signature.length() && signature.charAt(i + 1) == '"') {
state = state == EnumMapParsingState.IN_KEY ? EnumMapParsingState.IN_KEY_ESCAPE : EnumMapParsingState.IN_STR_VALUE_ESCAPE;
}
else if (state == EnumMapParsingState.IN_KEY) {
state = EnumMapParsingState.EXPECT_COLON;
}
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) {View on GitHub (pinned to 55bb57d202)
Solutions
- Remove the quotes so numeric values are bare: 'ENUM<bigint>{1: one, 2: two}'.
- Ensure the enum base type matches the value style — use ENUM<varchar> if values are quoted strings.
- Regenerate the signature from TypeSignatureSerialization so the format matches the declared base type.
Example fix
// before
"ENUM<bigint>{1: \"one\"}"
// after
"ENUM<bigint>{1: one}" Defensive patterns
Strategy: validation
Validate before calling
// bigint enums must not have quoted values
boolean isBigintEnum = signature.contains("ENUM<bigint>");
int colon = signature.indexOf(':');
if (isBigintEnum && colon != -1 && signature.charAt(signature.indexOf(':', colon + 1) + 1) == '"') {
throw new IllegalArgumentException("quoted value in numeric enum: " + signature);
} Type guard
static boolean valuesMatchEnumBase(String sig) {
boolean bigint = sig.contains("ENUM<bigint>");
boolean hasQuotedValue = sig.contains(": \\"") || sig.contains(":\"\"");
return bigint != hasQuotedValue || !bigint;
} Try / catch
try {
TypeSignature.parseTypeSignature(signature);
} catch (IllegalStateException e) {
if (e.getMessage().contains("varchar value in numeric enum")) {
// strip quotes from values or re-map to ENUM<varchar>
} else throw e;
} Prevention
- Match value style to the declared enum base type (bigint -> bare numbers, varchar -> quoted).
- Generate enum signatures with a single code path, never by hand.
- Round-trip enum signatures through toString/parse in tests.
When it happens
Trigger: Parsing a signature like 'ENUM<bigint>{1: "one"}' — i.e. a numeric enum whose value is quoted — via TypeSignature.parseTypeSignature / enumMapParsingData.
Common situations: Hand-written enum type signatures mixing value styles, code generators that emit quoted values regardless of base type, corrupted or edited persisted signatures.
Related errors
- Cannot parse enum signature
- Unexpected numeric value in varchar 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/58fc9210944ccfc2.
Report an issue: GitHub.