apache/shardingsphere · error · UnsupportedSQLOperationException
unsupported TableSegment type: %s
Error message
unsupported TableSegment type: %s
What it means
The final catch-all of ExpressionConverter.convert: after testing every supported ExpressionSegment subtype (literal, column, binary, unary, interval, subquery expressions, ...), an unrecognized segment class yields UnsupportedSQLOperationException with the segment's class name. It marks expression AST types the federation compiler cannot yet translate.
Source
Thrown at kernel/sql-federation/compiler/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/sql/ast/converter/segment/expression/ExpressionConverter.java:170
if (segment instanceof RowExpression) {
return Optional.of(RowExpressionConverter.convert((RowExpression) segment));
}
if (segment instanceof VariableSegment) {
return Optional.of(VariableSegmentConverter.convert((VariableSegment) segment));
}
if (segment instanceof UnaryOperationExpression) {
return Optional.of(UnaryOperationExpressionConverter.convert((UnaryOperationExpression) segment));
}
if (segment instanceof IntervalExpression) {
return Optional.of(IntervalExpressionConverter.convert((IntervalExpression) segment));
}
if (segment instanceof IntervalUnitExpression) {
return IntervalUnitExpressionConverter.convert((IntervalUnitExpression) segment);
}
if (segment instanceof QuantifySubqueryExpression) {
return Optional.of(QuantifySubqueryExpressionConverter.convert((QuantifySubqueryExpression) segment));
}
throw new UnsupportedSQLOperationException("unsupported TableSegment type: " + segment.getClass());
}
}
View on GitHub (pinned to e952770a21)
Solutions
- Simplify the SQL: replace the expression construct that produces the unrecognized segment with basic constructs (columns, literals, standard operators).
- Disable federation for the affected query or rule so it routes normally.
- Align proxy modules to one ShardingSphere version so parser segments and federation converters match.
- Report the segment class name shown in the message upstream.
Defensive patterns
Strategy: fallback
Try / catch
try {
rs = executeFederated(sql);
} catch (final SQLFederationUnsupportedSQLException ex) {
if (ex.getMessage().contains("unsupported TableSegment type")) { rs = executeRouted(sql); } else { throw ex; }
} Prevention
- Use same-version proxy modules so parser segments and converters stay in sync.
- Avoid novel SQL constructs in cross-shard queries when federation is enabled.
- Log the segment class name from the message to pinpoint unsupported syntax.
When it happens
Trigger: A federated query contains an expression segment type added or rarely used (e.g. a newer parser segment like CaseWhen or a dialect-specific expression) that reaches the converter without a matching branch; thrown during SqlNode conversion at compile time.
Common situations: Version skew: SQL parser produces newer segment types than the federation converter handles; unusual SQL constructs (special function expressions, XML/json expressions) in federated queries.
Related errors
- unsupported CommonExpressionSegment
- Unsupported interval unit
- Unsupported segment type: %s
- unsupported TextOrderByItemSegment
- SQL federation does not support SQL '%s'.
AI-assisted analysis of apache/shardingsphere@e952770a21 (2026-08-14).
Data as JSON: /api/errors/d5d380fdbc0fb72d.
Report an issue: GitHub.