prestodb/presto · error · SemanticException
NOT_SUPPORTED
NOT_SUPPORTED
Error message
Only column specifications connected by logical AND are supported in WHERE clause.
What it means
RefreshMaterializedViewPredicateAnalyzer.process validates that every node in a materialized view's refresh WHERE clause is a ComparisonExpression, LogicalBinaryExpression, or InPredicate. Any other expression shape (function calls, NOT, complex subqueries, arithmetic predicates, etc.) triggers NOT_SUPPORTED because only simple AND-connected column predicates can be used for incremental refresh partition pruning.
Source
Thrown at presto-main-base/src/main/java/com/facebook/presto/sql/analyzer/RefreshMaterializedViewPredicateAnalyzer.java:109
public Map<SchemaTableName, Expression> getTablePredicates()
{
ImmutableMap.Builder<SchemaTableName, Expression> tableConjuncts = ImmutableMap.builder();
tablePredicatesBuilder.build().asMap().forEach((table, predicateCollection) -> {
Optional<Expression> conjunctOptional = predicateCollection.stream()
.reduce((left, right) -> new LogicalBinaryExpression(LogicalBinaryExpression.Operator.AND, left, right));
conjunctOptional.ifPresent(conjunct -> tableConjuncts.put(table, conjunct));
});
return tableConjuncts.build();
}
@Override
public Void process(Node node, @Nullable Void context)
{
if (!(node instanceof ComparisonExpression || node instanceof LogicalBinaryExpression || node instanceof InPredicate)) {
throw new SemanticException(NOT_SUPPORTED, node, "Only column specifications connected by logical AND are supported in WHERE clause.");
}
return super.process(node, null);
}
@Override
protected Void visitExpression(Expression node, Void context)
{
throw new SemanticException(NOT_SUPPORTED, node, "Only column specifications connected by logical AND are supported in WHERE clause.");
}
@Override
protected Void visitLogicalBinaryExpression(LogicalBinaryExpression node, Void context)
{
if (LogicalBinaryExpression.Operator.OR.equals(node.getOperator())) {
SchemaTableName viewName = new SchemaTableName(viewDefinition.getSchema(), viewDefinition.getTable());
tablePredicatesBuilder.put(viewName, node);
return null;View on GitHub (pinned to 55bb57d202)
Solutions
- Rewrite the WHERE clause as conjunctions (AND) of simple comparison or IN predicates
- Remove NOT/complex expressions or rewrite them (e.g. a > 10 AND a < 20 instead of BETWEEN, invert NOT comparisons)
- Disable incremental refresh or use a full refresh if the complex predicate is required
Example fix
// before CREATE MATERIALIZED VIEW mv AS SELECT * FROM t WHERE NOT (a = 1); // after CREATE MATERIALIZED VIEW mv AS SELECT * FROM t WHERE a != 1;
Defensive patterns
Strategy: validation
Validate before calling
// Ensure the MV WHERE clause is only AND-connected comparisons/IN predicates before creating the view
for (Expression conjunct : extractConjuncts(whereClause)) {
if (!(conjunct instanceof ComparisonExpression) && !(conjunct instanceof InPredicate)) {
throw new IllegalArgumentException("Unsupported predicate in MV WHERE clause: " + conjunct);
}
} Type guard
boolean isSupportedPredicate(Expression e) { return e instanceof ComparisonExpression || e instanceof LogicalBinaryExpression || e instanceof InPredicate; } Try / catch
try { createMaterializedView(...); } catch (SemanticException e) { if (e.getCode() == NOT_SUPPORTED && e.getMessage().contains("WHERE clause")) { /* rewrite predicate or disable incremental refresh */ } else { throw e; } } Prevention
- Write MV WHERE clauses as ANDs of simple comparisons or IN lists
- Avoid NOT, OR over complex branches, and function-call predicates in refresh filters
- Prefer BETWEEN rewritten as two comparisons (a > x AND a < y)
When it happens
Trigger: Creating a materialized view whose WHERE clause contains unsupported constructs, e.g. NOT (...), OR with non-comparison branches, function-call predicates, or quantified/complex comparisons.
Common situations: Incremental materialized view refresh configuration with expressive filters that exceed the simple AND-of-comparisons subset the predicate analyzer supports.
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/265f16b48c57f0cf.
Report an issue: GitHub.