{"record":{"id":"00f437b85651e0db","repo":"apache/shardingsphere","slug":"unsupported-commonexpressionsegment","errorCode":null,"errorMessage":"unsupported CommonExpressionSegment","messagePattern":"unsupported CommonExpressionSegment","errorType":"exception","errorClass":"UnsupportedSQLOperationException","httpStatus":null,"severity":"error","filePath":"kernel/sql-federation/compiler/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/sql/ast/converter/segment/expression/ExpressionConverter.java","lineNumber":99,"sourceCode":"public final class ExpressionConverter {\n    \n    /**\n     * Convert expression segment to SQL node.\n     *\n     * @param segment expression segment\n     * @return SQL node\n     * @throws UnsupportedSQLOperationException unsupported SQL operation exception\n     */\n    public static Optional<SqlNode> convert(final ExpressionSegment segment) {\n        if (null == segment) {\n            return Optional.empty();\n        }\n        if (segment instanceof LiteralExpressionSegment) {\n            return LiteralExpressionConverter.convert((LiteralExpressionSegment) segment, null);\n        }\n        if (segment instanceof CommonExpressionSegment) {\n            // TODO\n            throw new UnsupportedSQLOperationException(\"unsupported CommonExpressionSegment\");\n        }\n        if (segment instanceof ListExpression) {\n            return ListExpressionConverter.convert((ListExpression) segment);\n        }\n        if (segment instanceof BinaryOperationExpression) {\n            return Optional.of(BinaryOperationExpressionConverter.convert((BinaryOperationExpression) segment));\n        }\n        if (segment instanceof ColumnSegment) {\n            return Optional.of(ColumnConverter.convert((ColumnSegment) segment));\n        }\n        if (segment instanceof ExistsSubqueryExpression) {\n            return Optional.of(ExistsSubqueryExpressionConverter.convert((ExistsSubqueryExpression) segment));\n        }\n        if (segment instanceof SubqueryExpressionSegment) {\n            return Optional.of(SubqueryExpressionConverter.convert((SubqueryExpressionSegment) segment));\n        }\n        if (segment instanceof InExpression) {\n            return Optional.of(InExpressionConverter.convert((InExpression) segment));","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/kernel/sql-federation/compiler/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/sql/ast/converter/segment/expression/ExpressionConverter.java#L81-L117","documentation":"While converting a parsed ShardingSphere expression tree into Apache Calcite SqlNodes for SQL federation, ExpressionConverter has no conversion for CommonExpressionSegment (a raw, unparsed expression fragment) and throws UnsupportedSQLOperationException. It is a marked TODO: expression shapes the parser kept as common text cannot be compiled by the federation compiler.","triggerScenarios":"A federated query contains an expression the SQL parser did not decompose into a known segment type (function calls, operators, or dialect-specific syntax kept verbatim), so the converter hits CommonExpressionSegment and fails during plan compilation.","commonSituations":"Federated SELECTs with uncommon scalar functions or operator syntax; queries relying on dialect-specific expressions; parser versions that fall back to common-expression capture for constructs they cannot fully parse.","solutions":["Rewrite the query to use standard SQL expressions the parser fully decomposes (avoid the construct that lands in CommonExpressionSegment).","Turn off SQL federation for this statement/rule (sql_federation execution mode NONE / rule-level disable) so it executes via normal routing.","Upgrade ShardingSphere — federation converter coverage grows over releases.","Extract the problematic expression into application-side computation if federation is otherwise required."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    rs = federationEngine.executeQuery(...);\n} catch (final UnsupportedSQLOperationException ex) {\n    // retry with federation disabled so the query routes normally\n    rs = routedExecute(sql, params);\n}","preventionTips":["Prefer fully-parsed standard SQL expressions in queries that must federate.","Smoke-test federated query shapes in CI to catch converter gaps early.","Keep a fallback path (federation off) for reports with exotic expressions."],"tags":["sql-federation","calcite","expression","converter"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}