apache/shardingsphere · error · UnsupportedOperationException
Unsupported Complex Expression
Error message
Unsupported Complex Expression
What it means
Thrown by OracleDMLStatementVisitor.createProjectionForComplexExpressionSegment when a projection recognized as 'complex' is neither a FunctionSegment, CommonExpressionSegment, nor one of the XML function segments (XmlQueryAndExists/XmlPi/XmlSerialize/XmlElement). The UnsupportedOperationException marks the unhandled complex-expression shape — a coverage gap for specific complex expression node types.
Source
Thrown at parser/sql/engine/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/engine/oracle/visitor/statement/type/OracleDMLStatementVisitor.java:1150
private ASTNode createProjectionForComplexExpressionSegment(final ASTNode projection, final AliasSegment alias) {
if (projection instanceof FunctionSegment) {
FunctionSegment segment = (FunctionSegment) projection;
ExpressionProjectionSegment result = new ExpressionProjectionSegment(segment.getStartIndex(), segment.getStopIndex(), segment.getText(), segment);
result.setAlias(alias);
return result;
}
if (projection instanceof CommonExpressionSegment) {
CommonExpressionSegment segment = (CommonExpressionSegment) projection;
ExpressionProjectionSegment result = new ExpressionProjectionSegment(segment.getStartIndex(), segment.getStopIndex(), segment.getText(), segment);
result.setAlias(alias);
return result;
}
if (projection instanceof XmlQueryAndExistsFunctionSegment || projection instanceof XmlPiFunctionSegment || projection instanceof XmlSerializeFunctionSegment
|| projection instanceof XmlElementFunctionSegment) {
return createExpressionProjectionSegment((ExpressionSegment) projection, alias);
}
throw new UnsupportedOperationException("Unsupported Complex Expression");
}
private ASTNode createProjectionForSimpleExpressionSegment(final ASTNode projection, final AliasSegment alias, final SelectProjectionExprClauseContext ctx) {
if (projection instanceof SubqueryExpressionSegment) {
SubqueryExpressionSegment subqueryExpressionSegment = (SubqueryExpressionSegment) projection;
String text = ctx.start.getInputStream().getText(new Interval(subqueryExpressionSegment.getStartIndex(), subqueryExpressionSegment.getStopIndex()));
SubqueryProjectionSegment result = new SubqueryProjectionSegment(((SubqueryExpressionSegment) projection).getSubquery(), text);
result.setAlias(alias);
return result;
}
if (projection instanceof LiteralExpressionSegment) {
LiteralExpressionSegment column = (LiteralExpressionSegment) projection;
ExpressionProjectionSegment result = null == alias
? new ExpressionProjectionSegment(column.getStartIndex(), column.getStopIndex(), column.getText(), column)
: new ExpressionProjectionSegment(column.getStartIndex(), ctx.alias().stop.getStopIndex(), column.getText(), column);
result.setAlias(alias);
return result;
}View on GitHub (pinned to e952770a21)
Solutions
- Flatten or alias the expression differently so it maps to FunctionSegment/CommonExpressionSegment
- Move the XML/complex function out of the projection or wrap it as a plain expression
- Upgrade ShardingSphere for wider complex-expression coverage
- Report the exact expression as an upstream grammar/visitor gap
Defensive patterns
Strategy: try-catch
Try / catch
try { parserEngine.parse(sql); } catch (UnsupportedOperationException e) { /* mark statement unsupported; route around proxy parsing if possible */ } Prevention
- Wrap XML/complex functions in simpler projection forms
- Maintain a regression corpus of Oracle projections parsed at build time
When it happens
Trigger: Oracle SQL using a complex expression whose visited node is typed as something else (e.g. certain collection/multiset expressions reaching this method only via the alias path, or newly introduced segment types); the instanceof chain exhausts and throws.
Common situations: Heavy use of Oracle XML functions or nested function expressions in sharded SELECTs; version drift adding segment classes; queries generated by ORMs with unusual expression trees.
Related errors
- Unhandled case
- Unsupported Simple Expression
- Unsupported Expression
- Unsupported Returning Expression
- Projections not in simple select, table subquery, join subqu
AI-assisted analysis of apache/shardingsphere@e952770a21 (2026-08-14).
Data as JSON: /api/errors/0437dac29b70eb70.
Report an issue: GitHub.