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 ancestors list opening '[' (found via the ", [" marker) is missing after the isOrderable field. Every serialized distinct type must end with '... , [ancestor1, ancestor2]}'; without the bracketed list the parser cannot read the top-most ancestor.
Source
Thrown at presto-common/src/main/java/com/facebook/presto/common/type/TypeSignature.java:333
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<>();
while (position < endIndex) {
int nextPositionIndex = signature.indexOf(", ", position);
if (nextPositionIndex == -1 || nextPositionIndex > endIndex) {
nextPositionIndex = endIndex;
}
otherAncestors.add(parseParentName(signature.substring(position, nextPositionIndex)).get());
position = nextPositionIndex + 2;
}
return new DistinctTypeParsingData(endIndex + 1, new DistinctTypeInfo(name, baseType, topMostAncestor, otherAncestors, isOrderable));
}View on GitHub (pinned to 55bb57d202)
Solutions
- Append an (possibly empty) ancestors list: 'name{baseType, true, []}'.
- Ensure there is a space after the comma before '[' — the parser searches for ", [".
- Regenerate the signature from the current Presto version's TypeSignature serialization to match the expected format.
Example fix
// before
"shop.customer_id{bigint, true}"
// after
"shop.customer_id{bigint, true, []}" Defensive patterns
Strategy: validation
Validate before calling
// require the ancestors list ' [ ... ]' before parsing
int open = signature.indexOf('{');
if (signature.indexOf(", [", open) == -1 || !signature.trim().endsWith("]}")) {
throw new IllegalArgumentException("distinct type signature missing ancestors list: " + signature);
} Type guard
static boolean hasAncestorList(String sig) {
return sig != null && sig.contains(", [") && sig.trim().endsWith("]}");
} Try / catch
try {
TypeSignature.parseTypeSignature(signature);
} catch (IllegalStateException e) {
if (e.getMessage().contains("expected '['")) {
// signature likely from an older format; re-serialize or reject
} else throw e;
} Prevention
- Always include the ancestors list, even when empty: ', []'.
- Re-serialize signatures stored by older engine versions before parsing.
- Check end-of-string for ']}' when accepting external signature input.
When it happens
Trigger: Parsing a signature like 'name{bigint, true}' or 'name{bigint, true no-ancestors}' where the ' [', ']' ancestor list portion is absent or malformed.
Common situations: Older serialized signatures from a previous format version that omitted the ancestors list, hand-truncated strings, connectors emitting a distinct-type format the current parser doesn't accept.
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/65b573b487184f9e.
Report an issue: GitHub.