{"record":{"id":"b9f98a8c6764e43b","repo":"prestodb/presto","slug":"not-supported-b9f98a","errorCode":"NOT_SUPPORTED","errorMessage":"Constraint %s of unknown type (%s) is not supported","messagePattern":"Constraint (.+?) of unknown type \\((.+?)\\) is not supported","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-spi/src/main/java/com/facebook/presto/spi/constraints/TableConstraintsHolder.java","lineNumber":49,"sourceCode":"public class TableConstraintsHolder\n{\n    private final List<TableConstraint<String>> tableConstraints;\n    private final Map<String, ColumnHandle> columnNameToHandleAssignments;\n\n    public TableConstraintsHolder(List<TableConstraint<String>> tableConstraints, Map<String, ColumnHandle> columnNameToHandleAssignments)\n    {\n        requireNonNull(tableConstraints, \"tableConstraints is null\");\n        requireNonNull(columnNameToHandleAssignments, \"columnNameToHandleAssignments is null\");\n        validateTableConstraints(tableConstraints);\n        this.tableConstraints = Collections.unmodifiableList(new ArrayList<>(tableConstraints));\n        this.columnNameToHandleAssignments = Collections.unmodifiableMap(columnNameToHandleAssignments);\n    }\n\n    public static void validateTableConstraints(Collection<TableConstraint<String>> constraints)\n    {\n        constraints.forEach(constraint -> {\n            if (!(constraint instanceof UniqueConstraint || constraint instanceof NotNullConstraint)) {\n                throw new PrestoException(NOT_SUPPORTED,\n                        format(\"Constraint %s of unknown type (%s) is not supported\", constraint.getName().orElse(\"\"), constraint.getClass().getName()));\n            }\n        });\n    }\n\n    public List<TableConstraint<String>> getTableConstraints()\n    {\n        return tableConstraints;\n    }\n\n    public List<TableConstraint<ColumnHandle>> getTableConstraintsWithColumnHandles()\n    {\n        if (columnNameToHandleAssignments.isEmpty()) {\n            return emptyList();\n        }\n        return rebaseTableConstraints(tableConstraints, columnNameToHandleAssignments);\n    }\n","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-spi/src/main/java/com/facebook/presto/spi/constraints/TableConstraintsHolder.java#L31-L67","documentation":"TableConstraintsHolder.validateTableConstraints guards the SPI contract that only UniqueConstraint and NotNullConstraint are supported table constraint types. If a connector or engine code passes any other TableConstraint subclass, this static validator throws NOT_SUPPORTED naming the constraint and its class.","triggerScenarios":"ConnectorMetadata methods that accept Collection<TableConstraint<String>> receiving a constraint type other than UniqueConstraint or NotNullConstraint (e.g. a custom or foreign-key-like constraint).","commonSituations":"Custom connector returning its own TableConstraint subclass; new constraint types added upstream but not handled; tooling forwarding database constraints (CHECK, FK) into the SPI.","solutions":["Convert the constraint to UniqueConstraint or NotNullConstraint before passing it into the SPI.","Filter out unsupported constraint types in your connector before validation.","Upgrade Presto if the constraint type should be supported in newer versions.","File/implement support in the connector for the new constraint kind."],"exampleFix":"// before\nconstraints.add(new CheckConstraint(\"chk\", expression)); // unsupported type\nvalidateTableConstraints(constraints);\n\n// after\nList<TableConstraint<String>> supported = constraints.stream()\n    .filter(c -> c instanceof UniqueConstraint || c instanceof NotNullConstraint)\n    .collect(toList());\nvalidateTableConstraints(supported);","handlingStrategy":"type-guard","validationCode":"if (constraints.stream().anyMatch(c -> !(c instanceof UniqueConstraint) && !(c instanceof NotNullConstraint))) {\n    throw new IllegalArgumentException(\"Only unique/not-null constraints are supported\");\n}","typeGuard":"boolean isSupportedConstraint(TableConstraint<String> c) {\n    return c instanceof UniqueConstraint || c instanceof NotNullConstraint;\n}","tryCatchPattern":"try {\n    TableConstraintsHolder.validateTableConstraints(constraints);\n} catch (PrestoException e) {\n    if (e.getErrorCode() == NOT_SUPPORTED.toErrorCode()) {\n        constraints = constraints.stream().filter(this::isSupportedConstraint).collect(toList());\n    } else throw e;\n}","preventionTips":["Only construct UniqueConstraint/NotNullConstraint when building SPI constraint collections.","Sanitize constraints imported from external catalogs.","Add unit tests asserting constraint types passed to SPI methods."],"tags":["presto","spi","constraints","not-supported","validation"],"backgroundTag":"connector-feature-not-supported","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"}