prestodb/presto · error · PrestoException
NOT_SUPPORTED
NOT_SUPPORTED
Error message
Constraint %s of unknown type (%s) is not supported
What it means
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.
Source
Thrown at presto-spi/src/main/java/com/facebook/presto/spi/constraints/TableConstraintsHolder.java:49
public class TableConstraintsHolder
{
private final List<TableConstraint<String>> tableConstraints;
private final Map<String, ColumnHandle> columnNameToHandleAssignments;
public TableConstraintsHolder(List<TableConstraint<String>> tableConstraints, Map<String, ColumnHandle> columnNameToHandleAssignments)
{
requireNonNull(tableConstraints, "tableConstraints is null");
requireNonNull(columnNameToHandleAssignments, "columnNameToHandleAssignments is null");
validateTableConstraints(tableConstraints);
this.tableConstraints = Collections.unmodifiableList(new ArrayList<>(tableConstraints));
this.columnNameToHandleAssignments = Collections.unmodifiableMap(columnNameToHandleAssignments);
}
public static void validateTableConstraints(Collection<TableConstraint<String>> constraints)
{
constraints.forEach(constraint -> {
if (!(constraint instanceof UniqueConstraint || constraint instanceof NotNullConstraint)) {
throw new PrestoException(NOT_SUPPORTED,
format("Constraint %s of unknown type (%s) is not supported", constraint.getName().orElse(""), constraint.getClass().getName()));
}
});
}
public List<TableConstraint<String>> getTableConstraints()
{
return tableConstraints;
}
public List<TableConstraint<ColumnHandle>> getTableConstraintsWithColumnHandles()
{
if (columnNameToHandleAssignments.isEmpty()) {
return emptyList();
}
return rebaseTableConstraints(tableConstraints, columnNameToHandleAssignments);
}
View on GitHub (pinned to 55bb57d202)
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.
Example fix
// before
constraints.add(new CheckConstraint("chk", expression)); // unsupported type
validateTableConstraints(constraints);
// after
List<TableConstraint<String>> supported = constraints.stream()
.filter(c -> c instanceof UniqueConstraint || c instanceof NotNullConstraint)
.collect(toList());
validateTableConstraints(supported); Defensive patterns
Strategy: type-guard
Validate before calling
if (constraints.stream().anyMatch(c -> !(c instanceof UniqueConstraint) && !(c instanceof NotNullConstraint))) {
throw new IllegalArgumentException("Only unique/not-null constraints are supported");
} Type guard
boolean isSupportedConstraint(TableConstraint<String> c) {
return c instanceof UniqueConstraint || c instanceof NotNullConstraint;
} Try / catch
try {
TableConstraintsHolder.validateTableConstraints(constraints);
} catch (PrestoException e) {
if (e.getErrorCode() == NOT_SUPPORTED.toErrorCode()) {
constraints = constraints.stream().filter(this::isSupportedConstraint).collect(toList());
} else throw e;
} Prevention
- 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.
When it happens
Trigger: 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).
Common situations: Custom connector returning its own TableConstraint subclass; new constraint types added upstream but not handled; tooling forwarding database constraints (CHECK, FK) into the SPI.
Understand the failure class
Background: Presto NOT_SUPPORTED error: what "not supported" means and how to fix it — this error's family across 3 libraries.
Related errors
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/b9f98a8c6764e43b.
Report an issue: GitHub.