MyCATApache/Mycat-Server · error · java.sql.SQLNonTransientException
can't find table define in schema
Error message
can't find table define in schema ${tableName} schema:${schema.getName()} What it means
Thrown when routing a district (dist) table and the table name from the SQL is not defined in the schema's tables map. Like the general table lookup, the dist-table path requires a TableConfig in schema.xml.
Solutions
- Declare the table in schema.xml with its distTables configuration and reload
- Match the table name casing used in schema.xml (Mycat upper-cases lookups)
- Confirm the client is using the correct Mycat schema name
Defensive patterns
Strategy: validation
Validate before calling
TableConfig tc = schema.getTables().get(tableName.toUpperCase());
if (tc == null) throw new IllegalArgumentException("dist table not defined: " + tableName); Try / catch
try { rrs = route(...); } catch (SQLNonTransientException e) { if (e.getMessage().startsWith("can't find table define")) { LOG.warn("check schema.xml dist table config"); } throw e; } Prevention
- Declare dist tables explicitly in schema.xml
- Standardize table-name casing across SQL and config
- Reload and verify config after dist-table changes
When it happens
Trigger: Calling the dist-table routing path (routeToDistTableNode flow) with a table that has no TableConfig in the current schema — table missing from schema.xml or name/case mismatch.
Common situations: distTables configured via placeholders but base table forgotten in schema.xml; SQL uses lowercase name while config uses uppercase; wrong logical schema selected.
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
- can't suport district table + tableName + schema: +…
- op table not in schema
- please make sure the primaryKey's config is not null in…
- can't find table define in schema
- can't find table define in schema
AI-assisted analysis of MyCATApache/Mycat-Server@65f8d8beb7 (2026-09-11).
Data as JSON: /api/errors/bfd0a085120cb4bc.
Report an issue: GitHub.
Appendix: source
Thrown at src/main/java/io/mycat/route/util/RouterUtil.java:1437
}
private static RouteResultset routeToDistTableNode(SchemaConfig schema, RouteResultset rrs,
String orgSql, Map<String, Map<String, Set<ColumnRoutePair>>> tablesAndConditions,
LayerCachePool cachePool, boolean isSelect, Map.Entry<String, Map<String, Set<ColumnRoutePair>>> entry) throws SQLNonTransientException {
String tableName = null;
if (entry != null) {
tableName = entry.getKey().toUpperCase();
} else {
List<String> tables = rrs.getTables();
tableName = tables.get(0);
}
TableConfig tableConfig = schema.getTables().get(tableName);
if(tableConfig == null) {
String msg = "can't find table define in schema " + tableName + " schema:" + schema.getName();
LOGGER.warn(msg);
throw new SQLNonTransientException(msg);
}
if(tableConfig.isGlobalTable()){
String msg = "can't suport district table " + tableName + " schema:" + schema.getName() + " for global table ";
LOGGER.warn(msg);
throw new SQLNonTransientException(msg);
}
String partionCol = tableConfig.getPartitionColumn();
// String primaryKey = tableConfig.getPrimaryKey();
//boolean isLoadData=false;
Set<String> tablesRouteSet = new HashSet<String>();
List<String> dataNodes = tableConfig.getDataNodes();
if(dataNodes.size()>1){
String msg = "can't suport district table " + tableName + " schema:" + schema.getName() + " for mutiple dataNode " + dataNodes;
LOGGER.warn(msg);
throw new SQLNonTransientException(msg);
}
View on GitHub (pinned to 65f8d8beb7)