{"record":{"id":"9aebf8e1d58b350c","repo":"MyCATApache/Mycat-Server","slug":"columnvalue-columnvalue-please-check-if-the-form-9aebf8","errorCode":null,"errorMessage":"columnValue:{columnValue} Please check if the format satisfied.","messagePattern":"columnValue:(.+?) Please check if the format satisfied\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/io/mycat/route/function/PartitionByDate.java","lineNumber":94,"sourceCode":"\t@Override\n\tpublic Integer calculate(String columnValue)  {\n\t\ttry {\n\t\t\tint targetPartition ;\n\t\t\tif(bNaturalDay){\n\t\t\t\tCalendar curTime = Calendar.getInstance();\n\t\t\t\tcurTime.setTime(formatter.get().parse(columnValue));\n\t\t\t\ttargetPartition = curTime.get(Calendar.DAY_OF_MONTH);\n\t\t\t\treturn  targetPartition-1;\n\t\t\t}\n\t\t\tlong targetTime = formatter.get().parse(columnValue).getTime();\n\t\t\ttargetPartition = (int) ((targetTime - beginDate) / partionTime);\n\t\t\tif(targetTime>endDate && nCount!=0) {\n\t\t\t\ttargetPartition = targetPartition % nCount;\n\t\t\t}\n\t\t\treturn targetPartition;\n\n\t\t} catch (ParseException e) {\n\t\t\tthrow new IllegalArgumentException(new StringBuilder().append(\"columnValue:\").append(columnValue).append(\" Please check if the format satisfied.\").toString(),e);\n\t\t}\n\t}\n\n\t@Override\n\tpublic Integer[] calculateRange(String beginValue, String endValue)  {\n\t\tSimpleDateFormat format = new SimpleDateFormat(this.dateFormat);\n\t\ttry {\n\t\t\tDate beginDate = format.parse(beginValue);\n\t\t\tDate endDate = format.parse(endValue);\n\t\t\tCalendar cal = Calendar.getInstance();\n\t\t\tList<Integer> list = new ArrayList<Integer>();\n\t\t\twhile(beginDate.getTime() <= endDate.getTime()){\n\t\t\t\tInteger nodeValue = this.calculate(format.format(beginDate));\n\t\t\t\tif(Collections.frequency(list, nodeValue) < 1) list.add(nodeValue);\n\t\t\t\tcal.setTime(beginDate);\n\t\t\t\tcal.add(Calendar.DATE, 1);\n\t\t\t\tbeginDate = cal.getTime();\n\t\t\t}","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/MyCATApache/Mycat-Server/blob/65f8d8beb752f935752f2a0eec0ab017facab9ef/src/main/java/io/mycat/route/function/PartitionByDate.java#L76-L112","documentation":"PartitionByDate.calculate() parses the column value with SimpleDateFormat using the configured dateFormat. When parsing fails (ParseException), it wraps it in this IllegalArgumentException. It means the sharding column value does not match the expected date pattern, so a partition cannot be computed.","triggerScenarios":"Inserting/selecting with a partition (date) column value like '2024/01/01' when dateFormat is 'yyyy-MM-dd', an empty or non-date string, or a truncated timestamp against the configured pattern.","commonSituations":"Application writes dates in a different locale/format than rule.xml's dateFormat; column contains datetime strings while pattern only covers dates; data migration brings in ISO-8601 values with 'T' separators.","solutions":["Make the column value match the dateFormat configured in rule.xml (or change dateFormat to match actual data).","Sanitize the value before it reaches routing (strip time portion, normalize separators).","Catch the IllegalArgumentException at the SQL layer and reject/log the malformed value at application level."],"exampleFix":"// before (data: '2024/01/01', rule dateFormat: yyyy-MM-dd)\nINSERT INTO t(id, created) VALUES(1, '2024/01/01');\n// after\nINSERT INTO t(id, created) VALUES(1, '2024-01-01');","handlingStrategy":"validation","validationCode":"boolean valid;\ntry {\n  new java.text.SimpleDateFormat(dateFormat).parse(columnValue);\n  valid = true;\n} catch (java.text.ParseException e) { valid = false; }\n","typeGuard":null,"tryCatchPattern":"try {\n    Integer node = partitionByDate.calculate(columnValue);\n} catch (IllegalArgumentException e) {\n    // log columnValue and configured dateFormat, reject row client-side\n}","preventionTips":["Always validate date strings against the rule's dateFormat before insert","Standardize date serialization (ISO yyyy-MM-dd) application-wide","Add unit tests feeding representative column values through calculate()"],"tags":["sharding","date-format","parsing"],"backgroundTag":"invalid-date-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"}