{"record":{"id":"1848eeb93649b1d1","repo":"apache/shardingsphere","slug":"1-1848ee","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/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/checker/ShardingTableRuleStatementChecker.java","lineNumber":270,"sourceCode":"            while (iterator.hasNext()) {\n                ShardingTable shardingTable = getShardingTable(iterator.next(), shardingTables);\n                if (!isValidActualDataSourceName(sampleShardingTable, shardingTable) || !isValidActualTableName(sampleShardingTable, shardingTable)) {\n                    return false;\n                }\n                if (isInvalidShardingAlgorithm(sampleShardingTable, shardingTable, true, checkedConfig) || isInvalidShardingAlgorithm(sampleShardingTable, shardingTable, false, checkedConfig)) {\n                    return false;\n                }\n            }\n        }\n        return true;\n    }\n    \n    private static ShardingTable getShardingTable(final String logicTableName, final Map<String, ShardingTable> shardingTables) {\n        ShardingTable result = shardingTables.get(logicTableName);\n        if (null != result) {\n            return result;\n        }\n        throw new ShardingTableRuleNotFoundException(Collections.singleton(logicTableName));\n    }\n    \n    private static boolean isValidActualDataSourceName(final ShardingTable sampleShardingTable, final ShardingTable shardingTable) {\n        return sampleShardingTable.getActualDataSourceNames().equals(shardingTable.getActualDataSourceNames());\n    }\n    \n    private static boolean isValidActualTableName(final ShardingTable sampleShardingTable, final ShardingTable shardingTable) {\n        for (String each : sampleShardingTable.getActualDataSourceNames()) {\n            Collection<String> sampleActualTableNames =\n                    sampleShardingTable.getActualTableNames(each).stream().map(actualTableName -> actualTableName.replace(sampleShardingTable.getTableDataNode().getPrefix(), \"\"))\n                            .collect(Collectors.toSet());\n            Collection<String> actualTableNames =\n                    shardingTable.getActualTableNames(each).stream().map(optional -> optional.replace(shardingTable.getTableDataNode().getPrefix(), \"\")).collect(Collectors.toSet());\n            if (!sampleActualTableNames.equals(actualTableNames)) {\n                return false;\n            }\n        }\n        return true;","sourceCodeStart":252,"sourceCodeEnd":288,"githubUrl":"https://github.com/apache/shardingsphere/blob/e952770a215630a3659c75d64369168cd3e26b82/features/sharding/distsql/handler/src/main/java/org/apache/shardingsphere/sharding/distsql/handler/checker/ShardingTableRuleStatementChecker.java#L252-L288","documentation":"ShardingTableRuleNotFoundException thrown by the DistSQL checker ShardingTableRuleStatementChecker.getShardingTable when a statement (e.g. ALTER SHARDING TABLE RULE, or checks that resolve a single existing rule) references a logic table that is not in the current sharding rule's shardingTables map. Unlike the routing variant, this fires at DistSQL execution time while validating the statement against existing configuration.","triggerScenarios":"Running ALTER SHARDING ... on a table name absent from the current rule; DROP/ALTER on a rule that was already dropped or renamed; case mismatch between the DistSQL table name and the configured logic table.","commonSituations":"Idempotent deployment scripts that re-run ALTER on possibly-dropped rules; renaming logic tables; environment drift where a rule exists in staging but not production.","solutions":["Run SHOW SHARDING TABLE RULES and use the exact configured logic table name (mind case).","Create the rule before altering it (CREATE SHARDING TABLE RULE if SHOW lists nothing).","In deployment scripts, guard the ALTER with an existence check or use IF EXISTS-style handling where supported."],"exampleFix":"-- before: t_order rule does not exist / name mismatch\nALTER SHARDING TABLE RULE t_Order (...);\n\n-- after: verify then alter the exact name\nSHOW SHARDING TABLE RULES;\nALTER SHARDING TABLE RULE t_order (...);","handlingStrategy":"validation","validationCode":"-- Guard deployment scripts\nSHOW SHARDING TABLE RULES;  -- confirm t_order exists with exact name/case before ALTER\n-- or in code: check rule metadata contains the logic table before issuing ALTER","typeGuard":null,"tryCatchPattern":"try {\n    executeDistSql(\"ALTER SHARDING TABLE RULE t_order (...)\");\n} catch (final ShardingTableRuleNotFoundException ex) {\n    // fall back to CREATE SHARDING TABLE RULE for a first-time deployment\n}","preventionTips":["Make rule-migration scripts idempotent: check existence, then CREATE or ALTER.","Match table-name case exactly as shown by SHOW SHARDING TABLE RULES."],"tags":["sharding","distsql","rule-not-found","configuration","alter"],"backgroundTag":null,"analyzedSha":"e952770a215630a3659c75d64369168cd3e26b82","analyzedAt":"2026-08-14T13:54:53.392Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}