{"record":{"id":"75084080ac60e595","repo":"MyCATApache/Mycat-Server","slug":"columnvalue-columnvalue-please-eliminate-any-qu","errorCode":null,"errorMessage":"columnValue:${columnValue} Please eliminate any quote and non number within it.","messagePattern":"columnValue:(.+?) Please eliminate any quote and non number within it\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/route/function/AutoPartitionByLong.java","lineNumber":73,"sourceCode":"\r\n\t@Override\r\n\tpublic Integer calculate(String columnValue)  {\r\n//\t\tcolumnValue = NumberParseUtil.eliminateQoute(columnValue);\r\n\t\ttry {\r\n\t\t\tlong value = Long.parseLong(columnValue);\r\n\t\t\tInteger rst = null;\r\n\t\t\tfor (LongRange longRang : this.longRongs) {\r\n\t\t\t\tif (value <= longRang.valueEnd && value >= longRang.valueStart) {\r\n\t\t\t\t\treturn longRang.nodeIndx;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\t//数据超过范围，暂时使用配置的默认节点\r\n\t\t\tif (rst == null && defaultNode >= 0) {\r\n\t\t\t\treturn defaultNode;\r\n\t\t\t}\r\n\t\t\treturn rst;\r\n\t\t} catch (NumberFormatException e){\r\n\t\t\tthrow new IllegalArgumentException(new StringBuilder().append(\"columnValue:\").append(columnValue).append(\" Please eliminate any quote and non number within it.\").toString(),e);\r\n\t\t}\r\n\t}\r\n\t\r\n\t@Override\r\n\tpublic Integer[] calculateRange(String beginValue, String endValue)  {\r\n\t\treturn AbstractPartitionAlgorithm.calculateSequenceRange(this, beginValue, endValue);\r\n\t}\r\n\r\n\t@Override\r\n\tpublic int getPartitionNum() {\r\n//\t\tint nPartition = longRongs.length;\r\n\t\t\r\n\t\t/*\r\n\t\t * fix #1284 这里的统计应该统计Range的nodeIndex的distinct总数\r\n\t\t */\r\n\t\tSet<Integer> distNodeIdxSet = new HashSet<Integer>();\r\n\t\tfor(LongRange range : longRongs) {\r\n\t\t\tdistNodeIdxSet.add(range.nodeIndx);\r","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/route/function/AutoPartitionByLong.java#L55-L91","documentation":"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.","triggerScenarios":"calculate(columnValue) is called with a string like \"123\", \"12.5\", \"abc\", or an empty string that Long.parseLong cannot parse.","commonSituations":"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.","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)."],"exampleFix":"// before\ninsert into t(id,name) values('10001','x');\n// after\ninsert into t(id,name) values(10001,'x');","handlingStrategy":"validation","validationCode":"boolean isValidShardKey(String v) {\n    return v != null && v.trim().matches(\"\\\\d+\");\n}","typeGuard":"Long parseShardKey(String v) {\n    try { return Long.parseLong(v.trim().replace(\"\\\"\", \"\")); }\n    catch (NumberFormatException e) { return null; }\n}","tryCatchPattern":"try {\n    insert(row);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"eliminate any quote\")) {\n        LOGGER.error(\"non-numeric sharding key: {}\", row.getKey());\n    } else { throw e; }\n}","preventionTips":["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"],"tags":["sharding","partition","numeric-parse","invalid-input"],"backgroundTag":"invalid-argument-format","analyzedSha":"65f8d8beb752f935752f2a0eec0ab017facab9ef","analyzedAt":"2026-09-11T00:12:21.696Z","contentChangedAt":"2026-09-11T00:12:21.696Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}