prestodb/presto · error · IllegalArgumentException

Unsupported set operation:

Error message

Unsupported set operation: 

What it means

Default case of the set-operation switch in AstBuilder: the parser produced a set operation token (UNION/INTERSECT/EXCEPT expected) that the builder does not recognize. Fires on grammar/AST drift or malformed query trees rather than ordinary user input; the message echoes the offending token text.

Source

Thrown at presto-parser/src/main/java/com/facebook/presto/sql/parser/AstBuilder.java:1277

        if (context.setQuantifier() != null) {
            if (context.setQuantifier().DISTINCT() != null) {
                distinct = Optional.of(true);
            }
            else if (context.setQuantifier().ALL() != null) {
                distinct = Optional.of(false);
            }
        }

        switch (context.operator.getType()) {
            case SqlBaseLexer.UNION:
                return new Union(getLocation(context.UNION()), ImmutableList.of(left, right), distinct);
            case SqlBaseLexer.INTERSECT:
                return new Intersect(getLocation(context.INTERSECT()), ImmutableList.of(left, right), distinct);
            case SqlBaseLexer.EXCEPT:
                return new Except(getLocation(context.EXCEPT()), left, right, distinct);
        }

        throw new IllegalArgumentException("Unsupported set operation: " + context.operator.getText());
    }

    @Override
    public Node visitSelectAll(SqlBaseParser.SelectAllContext context)
    {
        if (context.qualifiedName() != null) {
            return new AllColumns(getLocation(context), getQualifiedName(context.qualifiedName()));
        }

        return new AllColumns(getLocation(context));
    }

    @Override
    public Node visitSelectSingle(SqlBaseParser.SelectSingleContext context)
    {
        return new SingleColumn(
                getLocation(context),
                (Expression) visit(context.expression()),

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Use standard UNION, INTERSECT, or EXCEPT between queries
  2. Check the Presto/grammar version consistency if this appears with valid SQL
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at presto-parser/src/main/java/com/facebook/presto/sql/parser/AstBuilder.java:1277 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/6e07a1154d920420. Report an issue: GitHub.