{"record":{"id":"bd47b6b1550c8394","repo":"apache/shardingsphere","slug":"57","errorCode":"57","errorMessage":"Can not find routing table factor, data source '%s', actual table '%s'.","messagePattern":"Can not find routing table factor, data source '(.+?)', actual table '(.+?)'\\.","errorType":"exception","errorClass":"NoShardingTableRouteFactorException","httpStatus":null,"severity":"error","filePath":"features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/type/complex/ShardingCartesianRouteEngine.java","lineNumber":117,"sourceCode":"        List<Set<RouteMapper>> result = new ArrayList<>(actualTableGroups.size());\n        for (Set<String> each : actualTableGroups) {\n            Set<RouteMapper> routingTableGroup = new LinkedHashSet<>(each.size(), 1F);\n            for (String actualTable : each) {\n                routingTableGroup.add(findRoutingTable(dataSource, actualTable));\n            }\n            result.add(routingTableGroup);\n        }\n        return result;\n    }\n    \n    private RouteMapper findRoutingTable(final String dataSource, final String actualTable) {\n        for (RouteContext each : routeContexts) {\n            Optional<RouteMapper> result = each.findTableMapper(dataSource, actualTable);\n            if (result.isPresent()) {\n                return result.get();\n            }\n        }\n        throw new NoShardingTableRouteFactorException(dataSource, actualTable);\n    }\n    \n    private Collection<RouteUnit> getRouteUnits(final String dataSource, final Set<List<RouteMapper>> cartesianRoutingTableGroups) {\n        Collection<RouteUnit> result = new LinkedHashSet<>(cartesianRoutingTableGroups.size(), 1F);\n        RouteMapper dataSourceMapper = new RouteMapper(dataSource, dataSource);\n        for (List<RouteMapper> each : cartesianRoutingTableGroups) {\n            result.add(new RouteUnit(dataSourceMapper, new LinkedList<>(each)));\n        }\n        return result;\n    }\n}\n","sourceCodeStart":99,"sourceCodeEnd":129,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/type/complex/ShardingCartesianRouteEngine.java#L99-L129","documentation":"NoShardingTableRouteFactorException is thrown by ShardingCartesianRouteEngine when building the cartesian product of route contexts for a complex (multi-table) statement: for a given data source and actual table, no participating route context contains a matching table mapper (findTableMapper returns empty in every context). The engine cannot assemble a consistent routing table group, so it reports the missing routing factor with the data source and actual table names.","triggerScenarios":"Complex routing (SQL touching multiple sharded tables without a single common sharding key) where the per-table standard route contexts disagree: an actual table routed in one context has no counterpart mapper in the others for that data source — typically caused by inconsistent actualDataNodes/topology among tables in the statement.","commonSituations":"Joining sharded tables whose actual data node counts differ per data source; partially updated rules where one table was added to ds_1 but the other was not; binding-table groups containing tables with mismatched topologies.","solutions":["Align the actualDataNodes topology (same data sources, same per-data-source table counts) for every sharded table appearing in the statement.","Add an equality join condition on the binding/sharding keys so the statement uses binding-table routing instead of the cartesian engine.","Verify recently changed table rules were applied to all data sources (no stale rule metadata) — refresh the metadata or restart Proxy."],"exampleFix":"# before: t_order covers ds_0/ds_1, t_order_item only ds_0\nactualDataNodes: ds_${0..1}.t_order_${0..3}\nactualDataNodes: ds_0.t_order_item_${0..3}\n\n# after: aligned topologies\nactualDataNodes: ds_${0..1}.t_order_${0..3}\nactualDataNodes: ds_${0..1}.t_order_item_${0..3}","handlingStrategy":"try-catch","validationCode":"// Before running multi-table SQL, assert aligned topologies\nList<Integer> countsPerDs(ShardingTable t) { /* group actualDataNodes by ds, count */ return List.of(); }\nif (!countsPerDs(orderTable).equals(countsPerDs(itemTable))) {\n    throw new IllegalStateException(\"Topologies differ; complex routing will fail\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    rs = stmt.executeQuery(joinSql);\n} catch (final NoShardingTableRouteFactorException ex) {\n    // log ds + actual table from message; fix rule topology, then retry once after metadata refresh\n}","preventionTips":["Align actualDataNodes across tables joined in one statement.","Join on binding/sharding keys to use binding-table routing instead of cartesian routing.","After DistSQL rule edits, verify SHOW SHARDING TABLE RULES output before serving traffic."],"tags":["sharding","routing","complex-route","cartesian","topology"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}