{"record":{"id":"0437dac29b70eb70","repo":"apache/shardingsphere","slug":"unsupported-complex-expression","errorCode":null,"errorMessage":"Unsupported Complex Expression","messagePattern":"Unsupported Complex Expression","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"parser/sql/engine/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/engine/oracle/visitor/statement/type/OracleDMLStatementVisitor.java","lineNumber":1150,"sourceCode":"    \n    private ASTNode createProjectionForComplexExpressionSegment(final ASTNode projection, final AliasSegment alias) {\n        if (projection instanceof FunctionSegment) {\n            FunctionSegment segment = (FunctionSegment) projection;\n            ExpressionProjectionSegment result = new ExpressionProjectionSegment(segment.getStartIndex(), segment.getStopIndex(), segment.getText(), segment);\n            result.setAlias(alias);\n            return result;\n        }\n        if (projection instanceof CommonExpressionSegment) {\n            CommonExpressionSegment segment = (CommonExpressionSegment) projection;\n            ExpressionProjectionSegment result = new ExpressionProjectionSegment(segment.getStartIndex(), segment.getStopIndex(), segment.getText(), segment);\n            result.setAlias(alias);\n            return result;\n        }\n        if (projection instanceof XmlQueryAndExistsFunctionSegment || projection instanceof XmlPiFunctionSegment || projection instanceof XmlSerializeFunctionSegment\n                || projection instanceof XmlElementFunctionSegment) {\n            return createExpressionProjectionSegment((ExpressionSegment) projection, alias);\n        }\n        throw new UnsupportedOperationException(\"Unsupported Complex Expression\");\n    }\n    \n    private ASTNode createProjectionForSimpleExpressionSegment(final ASTNode projection, final AliasSegment alias, final SelectProjectionExprClauseContext ctx) {\n        if (projection instanceof SubqueryExpressionSegment) {\n            SubqueryExpressionSegment subqueryExpressionSegment = (SubqueryExpressionSegment) projection;\n            String text = ctx.start.getInputStream().getText(new Interval(subqueryExpressionSegment.getStartIndex(), subqueryExpressionSegment.getStopIndex()));\n            SubqueryProjectionSegment result = new SubqueryProjectionSegment(((SubqueryExpressionSegment) projection).getSubquery(), text);\n            result.setAlias(alias);\n            return result;\n        }\n        if (projection instanceof LiteralExpressionSegment) {\n            LiteralExpressionSegment column = (LiteralExpressionSegment) projection;\n            ExpressionProjectionSegment result = null == alias\n                    ? new ExpressionProjectionSegment(column.getStartIndex(), column.getStopIndex(), column.getText(), column)\n                    : new ExpressionProjectionSegment(column.getStartIndex(), ctx.alias().stop.getStopIndex(), column.getText(), column);\n            result.setAlias(alias);\n            return result;\n        }","sourceCodeStart":1132,"sourceCodeEnd":1168,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/parser/sql/engine/dialect/oracle/src/main/java/org/apache/shardingsphere/sql/parser/engine/oracle/visitor/statement/type/OracleDMLStatementVisitor.java#L1132-L1168","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { parserEngine.parse(sql); } catch (UnsupportedOperationException e) { /* mark statement unsupported; route around proxy parsing if possible */ }","preventionTips":["Wrap XML/complex functions in simpler projection forms","Maintain a regression corpus of Oracle projections parsed at build time"],"tags":["oracle","dml","complex-expression","projection","visitor"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}