MyCATApache/Mycat-Server · error · IllegalArgumentException
columnValue: Please eliminate any quote and non number…
Error message
columnValue:${columnValue} Please eliminate any quote and non number within it. What it means
AutoPartitionByLong.calculate parses the sharding column value as a long to look up the partition in the map file ranges. A NumberFormatException is rethrown as IllegalArgumentException telling the user the value contains quotes or non-numeric characters, because the rule expects a plain numeric string.
Solutions
- Strip quotes/whitespace and pass a plain numeric string as the sharding column value.
- Fix the application/ETL to send the numeric ID without quoting or decorations.
- Ensure the partition column in the SQL is the one configured in rule.xml (auto-sharding-long) and is numeric in the schema.
- If keys can legitimately be non-numeric, switch to a different partition algorithm (e.g. string hash).
Example fix
// before
insert into t(id,name) values('10001','x');
// after
insert into t(id,name) values(10001,'x'); Defensive patterns
Strategy: validation
Validate before calling
boolean isValidShardKey(String v) {
return v != null && v.trim().matches("\\d+");
} Type guard
Long parseShardKey(String v) {
try { return Long.parseLong(v.trim().replace("\"", "")); }
catch (NumberFormatException e) { return null; }
} Try / catch
try {
insert(row);
} catch (IllegalArgumentException e) {
if (e.getMessage().contains("eliminate any quote")) {
LOGGER.error("non-numeric sharding key: {}", row.getKey());
} else { throw e; }
} Prevention
- Keep sharding columns typed as BIGINT/INT in the schema
- Strip quotes/whitespace in ETL before writing
- Add app-level assertion that partition keys are numeric
When it happens
Trigger: calculate(columnValue) is called with a string like "123", "12.5", "abc", or an empty string that Long.parseLong cannot parse.
Common situations: Application sends quoted strings (e.g. from CSV/JSON ingestion) as partition keys; schema stores IDs as VARCHAR with whitespace/suffixes; route hint or insert passes the wrong column as the sharding key.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- columnValue: Please check if the format satisfied.
- can't find any valid datanode
- Can't find a valid data node for specified node index
- Can't find valid data node(s) for some of specified node…
- only one rule can defined
AI-assisted analysis of MyCATApache/Mycat-Server@65f8d8beb7 (2026-09-11).
Data as JSON: /api/errors/75084080ac60e595.
Report an issue: GitHub.
Appendix: source
Thrown at src/main/java/io/mycat/route/function/AutoPartitionByLong.java:73
@Override
public Integer calculate(String columnValue) {
// columnValue = NumberParseUtil.eliminateQoute(columnValue);
try {
long value = Long.parseLong(columnValue);
Integer rst = null;
for (LongRange longRang : this.longRongs) {
if (value <= longRang.valueEnd && value >= longRang.valueStart) {
return longRang.nodeIndx;
}
}
//数据超过范围,暂时使用配置的默认节点
if (rst == null && defaultNode >= 0) {
return defaultNode;
}
return rst;
} catch (NumberFormatException e){
throw new IllegalArgumentException(new StringBuilder().append("columnValue:").append(columnValue).append(" Please eliminate any quote and non number within it.").toString(),e);
}
}
@Override
public Integer[] calculateRange(String beginValue, String endValue) {
return AbstractPartitionAlgorithm.calculateSequenceRange(this, beginValue, endValue);
}
@Override
public int getPartitionNum() {
// int nPartition = longRongs.length;
/*
* fix #1284 这里的统计应该统计Range的nodeIndex的distinct总数
*/
Set<Integer> distNodeIdxSet = new HashSet<Integer>();
for(LongRange range : longRongs) {
distNodeIdxSet.add(range.nodeIndx);
View on GitHub (pinned to 65f8d8beb7)