{"record":{"id":"7e90649e6ffbcecb","repo":"apache/shardingsphere","slug":"1","errorCode":"1","errorMessage":"Can not find table rule with logic tables '%s'.","messagePattern":"Can not find table rule with logic tables '(.+?)'\\.","errorType":"exception","errorClass":"ShardingTableRuleNotFoundException","httpStatus":null,"severity":"error","filePath":"features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/type/complex/ShardingComplexRouteEngine.java","lineNumber":67,"sourceCode":"    private final ConfigurationProperties props;\n    \n    private final Collection<String> logicTables;\n    \n    @Override\n    public RouteContext route(final ShardingRule shardingRule) {\n        Collection<String> bindingTableNames = new CaseInsensitiveSet<>();\n        Collection<RouteContext> routeContexts = new LinkedList<>();\n        for (String each : logicTables) {\n            Optional<ShardingTable> shardingTable = shardingRule.findShardingTable(each);\n            if (shardingTable.isPresent()) {\n                if (!bindingTableNames.contains(each)) {\n                    routeContexts.add(new ShardingStandardRouteEngine(shardingTable.get().getLogicTable(), shardingConditions, sqlStatementContext, hintValueContext, props).route(shardingRule));\n                }\n                shardingRule.findBindingTableRule(each).ifPresent(optional -> bindingTableNames.addAll(optional.getShardingTables().keySet()));\n            }\n        }\n        if (routeContexts.isEmpty()) {\n            throw new ShardingTableRuleNotFoundException(logicTables);\n        }\n        RouteContext result = new RouteContext();\n        if (1 == routeContexts.size()) {\n            RouteContext newRouteContext = routeContexts.iterator().next();\n            result.getOriginalDataNodes().addAll(newRouteContext.getOriginalDataNodes());\n            result.getRouteUnits().addAll(newRouteContext.getRouteUnits());\n        } else {\n            RouteContext routeContext = new ShardingCartesianRouteEngine(routeContexts).route(shardingRule);\n            result.getOriginalDataNodes().addAll(routeContext.getOriginalDataNodes());\n            result.getRouteUnits().addAll(routeContext.getRouteUnits());\n        }\n        return result;\n    }\n}\n","sourceCodeStart":49,"sourceCodeEnd":82,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/features/sharding/core/src/main/java/org/apache/shardingsphere/sharding/route/engine/type/complex/ShardingComplexRouteEngine.java#L49-L82","documentation":"ShardingTableRuleNotFoundException ('Can not find table rule with logic tables') is thrown by ShardingComplexRouteEngine when none of the logic tables in a multi-table statement matches any sharding table rule: the loop over logicTables finds no shardingTable via shardingRule.findShardingTable, routeContexts stays empty, and the exception lists the logic tables. It means routing reached the complex engine (multiple tables involved) but no rule claims any of them.","triggerScenarios":"A SQL statement referencing multiple tables that are routed by the complex engine while none of the referenced table names exists in the sharding rule's tables/autoTables configuration (including case mismatches, missing default sharding strategy).","commonSituations":"Referencing a table not configured in the sharding rule (typo, wrong case on case-sensitive backends, table only present in some environments); removing a rule while the application still queries the table; missing default-database-strategy/table-strategy configuration.","solutions":["Add the reported logic table(s) to the sharding rule (tables or autoTables entry) or fix the table name/case in the SQL.","If the table is intentionally unsharded, configure a default strategy or move the table into a non-sharded schema/database handled by another rule.","After rule changes via DistSQL, confirm the altered rule is complete: ALTER SHARDING TABLE RULE must list all tables; verify with SHOW SHARDING TABLE RULES."],"exampleFix":"-- before: t_inventory missing from rule\nSELECT * FROM t_order o JOIN t_inventory i ON o.id=i.order_id;\n\n-- after: add rule for the missing table\nALTER SHARDING TABLE RULE t_inventory (\n  DATANODES(\"ds_${0..1}.t_inventory\"),\n  SHARDING_COLUMN(warehouse_id), TYPE(NAME=hash_mod, PROPERTIES(\"sharding-count\"=2))\n);","handlingStrategy":"validation","validationCode":"// Verify every table referenced by the statement has a rule before executing\nSet<String> referenced = Set.of(\"t_order\", \"t_inventory\");\nSet<String> configured = ruleMetaData.getConfiguration().getTables().stream()\n        .map(ShardingTableRuleConfiguration::getLogicTable)\n        .collect(Collectors.toSet());\nreferenced.stream().filter(Predicate.not(configured::contains)).findAny()\n        .ifPresent(t -> { throw new IllegalStateException(\"No sharding rule for \" + t); });","typeGuard":null,"tryCatchPattern":"try {\n    rs = stmt.executeQuery(sql);\n} catch (final ShardingTableRuleNotFoundException ex) {\n    // create the missing rule (or fix table name) then retry\n}","preventionTips":["Validate table names against SHOW SHARDING TABLE RULES in startup health checks.","Keep rule definitions in version control and apply them via a checked migration pipeline."],"tags":["sharding","routing","rule-not-found","configuration","complex-route"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}