prestodb/presto · error · IllegalStateException
Cannot parse distinct type definition(%s), expected ',' afte
Error message
Cannot parse distinct type definition(%s), expected ',' after position %s
What it means
Thrown by DistinctTypeParsingData.parse when the serialized distinct type signature lacks the first ", " separator after the '{' that opens the definition. The parser expects 'name{baseType, ...' and cannot find the comma following the base type. It indicates a malformed distinct-type signature string.
Source
Thrown at presto-common/src/main/java/com/facebook/presto/common/type/TypeSignature.java:321
this.distinctType = distinctType;
}
private static Optional<QualifiedObjectName> parseParentName(String s)
{
return s.equals("null") ? Optional.empty() : Optional.of(QualifiedObjectName.valueOf(s));
}
private static DistinctTypeParsingData parse(String signature, int startIndex)
{
int openBracketIndex = signature.indexOf("{", startIndex);
if (openBracketIndex == -1) {
throw new IllegalStateException(format("Cannot parse distinct type definition(%s), expected '{' after position %s", signature, startIndex));
}
QualifiedObjectName name = QualifiedObjectName.valueOf(signature.substring(startIndex, openBracketIndex));
int firstCommaIndex = signature.indexOf(", ", openBracketIndex);
if (firstCommaIndex == -1) {
throw new IllegalStateException(format("Cannot parse distinct type definition(%s), expected ',' after position %s", signature, openBracketIndex));
}
TypeSignature baseType = TypeSignature.parseTypeSignature(signature.substring(openBracketIndex + 1, firstCommaIndex));
int secondCommaIndex = signature.indexOf(", ", firstCommaIndex + 2);
if (secondCommaIndex == -1) {
throw new IllegalStateException(format("Cannot parse distinct type definition(%s), expected ',' after position %s", signature, secondCommaIndex));
}
boolean isOrderable = parseBoolean(signature.substring(firstCommaIndex + 2, secondCommaIndex));
int thirdCommaIndex = signature.indexOf(", [", secondCommaIndex + 2);
if (thirdCommaIndex == -1) {
throw new IllegalStateException(format("Cannot parse distinct type definition(%s), expected '[' after position %s", signature, secondCommaIndex));
}
Optional<QualifiedObjectName> topMostAncestor = parseParentName(signature.substring(secondCommaIndex + 2, thirdCommaIndex));
int endIndex = signature.indexOf("]}", thirdCommaIndex + 3);
int position = thirdCommaIndex + 3;
List<QualifiedObjectName> otherAncestors = new ArrayList<>();View on GitHub (pinned to 55bb57d202)
Solutions
- Ensure the signature contains all three fields separated by exactly ', ' (comma + space): 'name{baseType, orderable, [ancestors]}'.
- Regenerate the signature via TypeSignature.toString() instead of writing it by hand.
- If separators differ (e.g. ',' without space), fix the serializer; the parser requires the ", " substring.
Example fix
// before
"shop.customer_id{bigint,true,[]}" // no ', ' separators
// after
"shop.customer_id{bigint, true, []}" Defensive patterns
Strategy: validation
Validate before calling
// require ', ' separators between fields
if (!signature.contains("{")) throw new IllegalArgumentException("missing '{' in: " + signature);
int open = signature.indexOf('{');
if (!signature.substring(open).contains(", ")) {
throw new IllegalArgumentException("distinct type signature missing ', ' separators: " + signature);
} Type guard
static boolean hasCommaSpaceSeparators(String sig) {
if (sig == null) return false;
int open = sig.indexOf('{');
return open >= 0 && sig.indexOf(", ", open) > 0;
} Try / catch
try {
TypeSignature.parseTypeSignature(signature);
} catch (IllegalStateException e) {
if (e.getMessage().contains("expected ','")) {
// regenerate from canonical serialization or reject input
} else throw e;
} Prevention
- Use exactly comma+space ('\", \"') between distinct-type fields.
- Build signatures with TypeSignature objects, not string concatenation.
- Round-trip test signatures in CI.
When it happens
Trigger: Parsing a distinct type signature where the base type is not followed by ', ' — e.g. 'name{bigint true, []}' or 'name{bigint}' with the orderable/ancestors fields missing entirely.
Common situations: Manually constructing signatures for tests, a signature truncated after the base type, connectors or plugins that serialize distinct types with a non-standard separator (e.g. single comma without space — the parser searches for ", " exactly).
Related errors
- Cannot parse distinct type definition(%s), expected '{' afte
- Cannot parse distinct type definition(%s), expected '[' afte
- Bad type signature: '%s'
- Unexpected varchar value in numeric enum signature
- Cannot parse enum signature
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/2a37e7852c9f4754.
Report an issue: GitHub.