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
PartitionByRangeMod.calculate() converts the sharding column value to a long to locate the range and apply modulo. A NumberFormatException from Long.parseLong is rethrown as this IllegalArgumentException instructing the user to remove quotes and non-numeric characters from the value.
Solutions
- Strip quotes and non-digit characters from the value before passing it to calculate().
- Confirm the sharding column is numeric; if not, choose a string-compatible partition function.
- Where feasible, configure the table column as a numeric type so the driver/parser delivers unquoted values.
- Catch IllegalArgumentException in the routing layer and surface the raw columnValue in the client error for diagnosis.
Example fix
// before
calculate(" 1001x"); // IllegalArgumentException
// after
calculate("1001x".replaceAll("[^0-9-]", "")); // 1001, routes normally Defensive patterns
Strategy: validation
Validate before calling
if (columnValue == null || !columnValue.toString().trim().matches("-?\\d+")) throw new IllegalArgumentException("range-mod sharding needs a numeric value: " + columnValue); Type guard
Long asLong(Object v) {
if (v == null) return null;
try { return Long.valueOf(v.toString().trim().replace("'", "")); }
catch (NumberFormatException e) { return null; }
} Try / catch
try { idx = rule.calculate(value); } catch (IllegalArgumentException e) { /* clean the value or route to defaultNode; log raw value */ } Prevention
- Only assign PartitionByRangeMod to numeric columns.
- Strip quotes and whitespace from string values before routing.
- Use the rule's defaultNode for out-of-range values to avoid hard failures where business-appropriate.
When it happens
Trigger: calculate() is called with a non-numeric value: a string wrapped in quotes ("'42'"), alphanumeric IDs, values with spaces or separators, or empty/null strings that fail Long.parseLong.
Common situations: Sharding a VARCHAR column holding non-numeric data with a numeric range rule; ORM or SQL parser passing the literal including quotes; ETL delivering values with thousands separators ('1,000') or currency signs; users pointing a range-mod rule at a string key by mistake.
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 eliminate any quote and non number…
- columnValue: Please check if the format satisfied.
- columnValue: Please eliminate any quote and non number…
- columnValue: Please check if the format satisfied.
- only one rule can defined
AI-assisted analysis of MyCATApache/Mycat-Server@65f8d8beb7 (2026-09-11).
Data as JSON: /api/errors/9660891622bd20be.
Report an issue: GitHub.
Appendix: source
Thrown at src/main/java/io/mycat/route/function/PartitionByRangeMod.java:78
long value = Long.parseLong(columnValue);
Integer rst = null;
int nodeIndex = 0;
for (LongRange longRang : this.longRanges) {
if (value <= longRang.valueEnd && value >= longRang.valueStart) {
BigInteger bigNum = new BigInteger(columnValue).abs();
int innerIndex = (bigNum.mod(BigInteger.valueOf(longRang.groupSize))).intValue();
return nodeIndex + innerIndex;
} else {
nodeIndex += longRang.groupSize;
}
}
//数据超过范围,暂时使用配置的默认节点
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 int getPartitionNum() {
int nPartition = 0;
for(LongRange longRange : this.longRanges) {
nPartition += longRange.groupSize;
}
return nPartition;
}
public Integer calculateStart(String columnValue) {
long value = Long.parseLong(columnValue);
Integer rst = null;
int nodeIndex=0;
for (LongRange longRang : this.longRanges) {
if (value <= longRang.valueEnd && value >= longRang.valueStart) {View on GitHub (pinned to 65f8d8beb7)