MyCATApache/Mycat-Server · error · SQLSyntaxErrorException
partition table, insert must provide ColumnList
Error message
partition table, insert must provide ColumnList
What it means
For a sharded (partitioned) table with a configured partitionColumn, Mycat needs the sharding column's value to compute the target node. If the INSERT statement has no column list (INSERT INTO t VALUES (...) or empty columns), the partition column value cannot be located, so SQLSyntaxErrorException is thrown.
Solutions
- Always write an explicit column list in INSERTs to sharded tables: INSERT INTO t (id, name, sharding_col) VALUES (...).
- If the column list is intentionally omitted, remove partitionColumn from the table config or switch to a non-sharded/global table.
- Ensure the partition column itself is included in the column list.
Example fix
// before INSERT INTO orders VALUES (1, 'x', 100); // after INSERT INTO orders (id, name, customer_id) VALUES (1, 'x', 100);
Defensive patterns
Strategy: validation
Validate before calling
// Ensure INSERTs to sharded tables carry an explicit column list
function validateInsert(sql, shardedTables) {
const m = /^\s*INSERT\s+INTO\s+[`\"]?(\w+)[`\"]?\s*VALUES/i.exec(sql);
if (m && shardedTables.includes(m[1].toUpperCase())) {
throw new Error("INSERT into sharded table " + m[1] + " requires an explicit column list");
}
} Prevention
- Ban column-less INSERT syntax in coding standards for sharded tables.
- Configure ORMs to always emit explicit column lists.
When it happens
Trigger: INSERT INTO sharded_table VALUES (...) without an explicit column list on a table whose <table> config defines a partitionColumn; insert.getColumns() null or empty in statementParse.
Common situations: ORMs generating column-less INSERTs; scripts copied from single-node MySQL usage; tables whose partitionColumn was recently added to config while old SQL lacked the column list.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- bad insert sql columnSize != valueSize:values:
- insert must provide ColumnList
- parent key can't find valid datanode ,expect 1 but found
- route rule for table
- "bad insert sql (sharding column:"+ partitionColumn + " not…
AI-assisted analysis of MyCATApache/Mycat-Server@65f8d8beb7 (2026-09-11).
Data as JSON: /api/errors/a4a6005498bacc5c.
Report an issue: GitHub.
Appendix: source
Thrown at src/main/java/io/mycat/route/parser/druid/impl/DruidInsertParser.java:77
TableConfig tc = schema.getTables().get(tableName);
if(tc == null) {
String msg = "can't find table define in schema "
+ tableName + " schema:" + schema.getName();
LOGGER.warn(msg);
throw new SQLNonTransientException(msg);
} else {
//childTable的insert直接在解析过程中完成路由
if (tc.isChildTable()) {
parserChildTable(schema, rrs, tableName, insert);
return;
}
String partitionColumn = tc.getPartitionColumn();
if(partitionColumn != null) {//分片表
//拆分表必须给出column list,否则无法寻找分片字段的值
if(insert.getColumns() == null || insert.getColumns().size() == 0) {
throw new SQLSyntaxErrorException("partition table, insert must provide ColumnList");
}
//批量insert
if(isMultiInsert(insert)) {
// String msg = "multi insert not provided" ;
// LOGGER.warn(msg);
// throw new SQLNonTransientException(msg);
parserBatchInsert(schema, rrs, partitionColumn, tableName, insert);
} else {
parserSingleInsert(schema, rrs, partitionColumn, tableName, insert);
}
}
}
}
/**
* 寻找joinKey的索引View on GitHub (pinned to 65f8d8beb7)