{"record":{"id":"1ac9a51f560a0bfa","repo":"apache/shardingsphere","slug":"unsupported-segment-type-s","errorCode":null,"errorMessage":"Unsupported segment type: %s","messagePattern":"Unsupported segment type: (.+?)","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/from/TableConverter.java","lineNumber":65,"sourceCode":"     * @throws UnsupportedSQLOperationException unsupported SQL operation exception\n     */\n    public static Optional<SqlNode> convert(final TableSegment segment) {\n        if (null == segment) {\n            return Optional.empty();\n        }\n        if (segment instanceof SimpleTableSegment) {\n            return SimpleTableConverter.convert((SimpleTableSegment) segment);\n        }\n        if (segment instanceof JoinTableSegment) {\n            return JoinTableConverter.convert((JoinTableSegment) segment);\n        }\n        if (segment instanceof SubqueryTableSegment) {\n            return SubqueryTableConverter.convert((SubqueryTableSegment) segment);\n        }\n        if (segment instanceof DeleteMultiTableSegment) {\n            return DeleteMultiTableConverter.convert((DeleteMultiTableSegment) segment);\n        }\n        throw new UnsupportedSQLOperationException(\"Unsupported segment type: \" + segment.getClass());\n    }\n}\n","sourceCodeStart":47,"sourceCodeEnd":68,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/kernel/sql-federation/compiler/src/main/java/org/apache/shardingsphere/sqlfederation/compiler/sql/ast/converter/segment/from/TableConverter.java#L47-L68","documentation":"TableConverter.convert dispatches on the FROM-clause table segment type: SimpleTableSegment, JoinTableSegment, SubqueryTableSegment, and DeleteMultiTableSegment are handled; any other TableSegment subclass throws UnsupportedSQLOperationException with the class name. Federation compilation only supports these table reference shapes.","triggerScenarios":"A federated query's FROM clause contains a table reference the converter does not model — e.g. a VALUES clause table, LATERAL table, function table (unnest/generate_series), or a newer parser segment type — reaching convert() during compilation.","commonSituations":"Queries with table-valued functions or CTE-only shapes; parser versions that produce distinct segment classes for exotic FROM items; dialect-specific joins.","solutions":["Restructure the query so FROM items are plain tables, joins of tables, or subqueries with aliases.","Replace table-valued functions / LATERAL references with subqueries the converter supports.","Disable federation for this query so it executes on the storage directly."],"exampleFix":"-- before\nSELECT * FROM GENERATE_SERIES(1, 10) AS g(n);\n-- after\nSELECT * FROM (SELECT 1 AS n UNION ALL SELECT 2) AS g;","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    rs = executeFederated(sql);\n} catch (final SQLFederationUnsupportedSQLException ex) {\n    if (ex.getMessage().contains(\"Unsupported segment type\")) { rs = executeOnSingleStorage(sql); } else { throw ex; }\n}","preventionTips":["Keep FROM clauses to plain tables, joins, and aliased subqueries.","Avoid table-valued functions and LATERAL in federated queries.","Provide a non-federated execution path for reporting SQL."],"tags":["sql-federation","from-clause","calcite","converter"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}