{"record":{"id":"65b573b487184f9e","repo":"prestodb/presto","slug":"cannot-parse-distinct-type-definition-s-expecte-65b573","errorCode":null,"errorMessage":"Cannot parse distinct type definition(%s), expected '[' after position %s","messagePattern":"Cannot parse distinct type definition\\((.+?)\\), expected '\\[' after position (.+?)","errorType":"validation","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"presto-common/src/main/java/com/facebook/presto/common/type/TypeSignature.java","lineNumber":333,"sourceCode":"                throw new IllegalStateException(format(\"Cannot parse distinct type definition(%s), expected '{' after position %s\", signature, startIndex));\n            }\n            QualifiedObjectName name = QualifiedObjectName.valueOf(signature.substring(startIndex, openBracketIndex));\n\n            int firstCommaIndex = signature.indexOf(\", \", openBracketIndex);\n            if (firstCommaIndex == -1) {\n                throw new IllegalStateException(format(\"Cannot parse distinct type definition(%s), expected ',' after position %s\", signature, openBracketIndex));\n            }\n            TypeSignature baseType = TypeSignature.parseTypeSignature(signature.substring(openBracketIndex + 1, firstCommaIndex));\n\n            int secondCommaIndex = signature.indexOf(\", \", firstCommaIndex + 2);\n            if (secondCommaIndex == -1) {\n                throw new IllegalStateException(format(\"Cannot parse distinct type definition(%s), expected ',' after position %s\", signature, secondCommaIndex));\n            }\n            boolean isOrderable = parseBoolean(signature.substring(firstCommaIndex + 2, secondCommaIndex));\n\n            int thirdCommaIndex = signature.indexOf(\", [\", secondCommaIndex + 2);\n            if (thirdCommaIndex == -1) {\n                throw new IllegalStateException(format(\"Cannot parse distinct type definition(%s), expected '[' after position %s\", signature, secondCommaIndex));\n            }\n            Optional<QualifiedObjectName> topMostAncestor = parseParentName(signature.substring(secondCommaIndex + 2, thirdCommaIndex));\n\n            int endIndex = signature.indexOf(\"]}\", thirdCommaIndex + 3);\n            int position = thirdCommaIndex + 3;\n            List<QualifiedObjectName> otherAncestors = new ArrayList<>();\n\n            while (position < endIndex) {\n                int nextPositionIndex = signature.indexOf(\", \", position);\n                if (nextPositionIndex == -1 || nextPositionIndex > endIndex) {\n                    nextPositionIndex = endIndex;\n                }\n                otherAncestors.add(parseParentName(signature.substring(position, nextPositionIndex)).get());\n                position = nextPositionIndex + 2;\n            }\n\n            return new DistinctTypeParsingData(endIndex + 1, new DistinctTypeInfo(name, baseType, topMostAncestor, otherAncestors, isOrderable));\n        }","sourceCodeStart":315,"sourceCodeEnd":351,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-common/src/main/java/com/facebook/presto/common/type/TypeSignature.java#L315-L351","documentation":"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.","triggerScenarios":"Parsing a signature like 'name{bigint, true}' or 'name{bigint, true no-ancestors}' where the ' [', ']' ancestor list portion is absent or malformed.","commonSituations":"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.","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."],"exampleFix":"// before\n\"shop.customer_id{bigint, true}\"\n// after\n\"shop.customer_id{bigint, true, []}\"","handlingStrategy":"validation","validationCode":"// require the ancestors list ' [ ... ]' before parsing\nint open = signature.indexOf('{');\nif (signature.indexOf(\", [\", open) == -1 || !signature.trim().endsWith(\"]}\")) {\n    throw new IllegalArgumentException(\"distinct type signature missing ancestors list: \" + signature);\n}","typeGuard":"static boolean hasAncestorList(String sig) {\n    return sig != null && sig.contains(\", [\") && sig.trim().endsWith(\"]}\");\n}","tryCatchPattern":"try {\n    TypeSignature.parseTypeSignature(signature);\n} catch (IllegalStateException e) {\n    if (e.getMessage().contains(\"expected '['\")) {\n        // signature likely from an older format; re-serialize or reject\n    } else throw e;\n}","preventionTips":["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."],"tags":["presto","type-signature","parsing","distinct-type"],"backgroundTag":"type-signature-parse-failure","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}