{"record":{"id":"d5b4843be2a2fab9","repo":"prestodb/presto","slug":"cannot-parse-distinct-type-definition-s-expecte","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":315,"sourceCode":"        private final int endIndex;\n        private final DistinctTypeInfo distinctType;\n\n        private DistinctTypeParsingData(int endIndex, DistinctTypeInfo distinctType)\n        {\n            this.endIndex = endIndex;\n            this.distinctType = distinctType;\n        }\n\n        private static Optional<QualifiedObjectName> parseParentName(String s)\n        {\n            return s.equals(\"null\") ? Optional.empty() : Optional.of(QualifiedObjectName.valueOf(s));\n        }\n\n        private static DistinctTypeParsingData parse(String signature, int startIndex)\n        {\n            int openBracketIndex = signature.indexOf(\"{\", startIndex);\n            if (openBracketIndex == -1) {\n                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));","sourceCodeStart":297,"sourceCodeEnd":333,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-common/src/main/java/com/facebook/presto/common/type/TypeSignature.java#L297-L333","documentation":"This error is thrown by DistinctTypeParsingData.parse in TypeSignature while parsing a serialized distinct type signature (format: name{baseType, orderable, [ancestors]}). It means the '{' character that must follow the distinct type's qualified name was not found at or after startIndex. The library throws it because a signature string reaching this parser is malformed relative to the expected distinct-type serialization layout.","triggerScenarios":"Calling TypeSignature.parseTypeSignature (or parsing a signature containing 'DISTINCT <name>...') where the text after the type name has no '{' character — e.g. 'DISTINCT myschema.mytype base, true, []}' missing the brace, or a truncated signature.","commonSituations":"Hand-editing serialized type signatures, corruption of type signatures persisted in catalogs/metadata, version mismatch where a connector emits an older or custom distinct-type format, truncation when copying signature strings.","solutions":["Check the signature string and ensure it contains '{' immediately after the distinct type's qualified name, e.g. 'cat.schema.type{baseType, true, []}'.","Verify the signature was produced by TypeSignature.toString()/TypeSignatureBase of the same Presto version — regenerate it rather than hand-editing.","Log and inspect the full signature at the startIndex reported by the message to spot truncation or whitespace/encoding corruption."],"exampleFix":"// before (malformed)\nTypeSignature.parseTypeSignature(\"DISTINCT shop.customer_id bigint, true, []}\");\n// after\nTypeSignature.parseTypeSignature(\"DISTINCT shop.customer_id{bigint, true, []}\");","handlingStrategy":"validation","validationCode":"// pre-validate a distinct type signature before parsing\nboolean hasOpenBrace = signature != null && signature.contains(\"{\");\nif (!hasOpenBrace) {\n    throw new IllegalArgumentException(\"Malformed distinct type signature (missing '{'): \" + signature);\n}","typeGuard":"static boolean looksLikeDistinctType(String sig) {\n    return sig != null && sig.matches(\".*\\\\{.*,.*\\\\}\\\\s*$\");\n}","tryCatchPattern":"try {\n    TypeSignature ts = TypeSignature.parseTypeSignature(signature);\n} catch (IllegalStateException e) {\n    if (e.getMessage().contains(\"expected '{'\")) {\n        // log full signature, fall back to raw VARCHAR type\n    } else throw e;\n}","preventionTips":["Never hand-edit serialized type signatures; regenerate via TypeSignature.toString().","Validate signatures round-trip (parse then re-serialize and compare) in tests.","Watch for truncation when signatures cross log/storage boundaries."],"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"}