apache/shardingsphere · error · UnsupportedOperationException

Unsupported Expression

Error message

Unsupported Expression

What it means

Thrown by OracleDMLStatementVisitor.createProjectionForExpressionSegment, the final fallback in Oracle projection mapping. It handles Column, BinaryOperation, Multiset, Datetime, IntervalExpressionProjection, and the CaseWhen/Unary/Variable/Between/In/Collate group; anything else reaching this method throws UnsupportedOperationException('Unsupported Expression'). This is the last-resort marker for projection node types the Oracle visitor cannot yet translate.

Source

Thrown at parser/sql/engine/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/engine/oracle/visitor/statement/type/OracleDMLStatementVisitor.java:1193

            return createColumnProjectionSegment((ColumnSegment) projection, alias);
        }
        if (projection instanceof BinaryOperationExpression) {
            return createExpressionProjectionSegment((BinaryOperationExpression) projection, alias);
        }
        if (projection instanceof MultisetExpression) {
            return createExpressionProjectionSegment((MultisetExpression) projection, alias);
        }
        if (projection instanceof DatetimeExpression) {
            return createDatetimeProjectionSegment((DatetimeExpression) projection);
        }
        if (projection instanceof IntervalExpressionProjection) {
            return createIntervalExpressionProjection((IntervalExpressionProjection) projection);
        }
        if (projection instanceof CaseWhenExpression || projection instanceof UnaryOperationExpression || projection instanceof VariableSegment
                || projection instanceof BetweenExpression || projection instanceof InExpression || projection instanceof CollateExpression) {
            return createExpressionProjectionSegment((ExpressionSegment) projection, alias);
        }
        throw new UnsupportedOperationException("Unsupported Expression");
    }
    
    private ColumnProjectionSegment createColumnProjectionSegment(final ColumnSegment projection, final AliasSegment alias) {
        ColumnProjectionSegment result = new ColumnProjectionSegment(projection);
        result.setAlias(alias);
        return result;
    }
    
    private ExpressionProjectionSegment createExpressionProjectionSegment(final BinaryOperationExpression projection, final AliasSegment alias) {
        int startIndex = projection.getStartIndex();
        int stopIndex = null == alias ? projection.getStopIndex() : alias.getStopIndex();
        ExpressionProjectionSegment result = new ExpressionProjectionSegment(startIndex, stopIndex, projection.getText(), projection);
        result.setAlias(alias);
        return result;
    }
    
    private ExpressionProjectionSegment createExpressionProjectionSegment(final MultisetExpression projection, final AliasSegment alias) {
        int startIndex = projection.getStartIndex();

View on GitHub (pinned to e952770a21)

Solutions

  1. Rewrite the projection using handled constructs (columns, arithmetic, CASE WHEN, literals)
  2. Bypass ShardingSphere parsing for that statement if routing allows (run it directly)
  3. Upgrade ShardingSphere and retest — the handled list grows over versions
  4. Contribute a branch for the missing ExpressionSegment subtype upstream
Defensive patterns

Strategy: try-catch

Try / catch

try { parserEngine.parse(sql); } catch (UnsupportedOperationException e) { logUnsupportedExpression(sql); return directRoute(sql); }

Prevention

When it happens

Trigger: Oracle SELECT projections containing expression shapes outside the handled list — e.g. certain analytic-function segments, newly added segment types, or expressions whose visited class fails every instanceof in the chain. It is triggered only after the alias, complex, and simple branches in 613/614/615 did not match.

Common situations: Advanced Oracle SQL (analytic functions, model clauses, exotic operators) routed through ShardingSphere; incremental grammar upgrades that add classes without visitor branches; ORM-generated expression trees.

Related errors


AI-assisted analysis of apache/shardingsphere@e952770a21 (2026-08-14). Data as JSON: /api/errors/a277a04fdd1df41d. Report an issue: GitHub.