MyCATApache/Mycat-Server · error · IllegalArgumentException

columnValue: Please check if the format satisfied.

Error message

columnValue:{columnValue} Please check if the format satisfied.

What it means

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.

Solutions

  1. Make the column value match the dateFormat configured in rule.xml (or change dateFormat to match actual data).
  2. Sanitize the value before it reaches routing (strip time portion, normalize separators).
  3. Catch the IllegalArgumentException at the SQL layer and reject/log the malformed value at application level.

Example fix

// before (data: '2024/01/01', rule dateFormat: yyyy-MM-dd)
INSERT INTO t(id, created) VALUES(1, '2024/01/01');
// after
INSERT INTO t(id, created) VALUES(1, '2024-01-01');
Defensive patterns

Strategy: validation

Validate before calling

boolean valid;
try {
  new java.text.SimpleDateFormat(dateFormat).parse(columnValue);
  valid = true;
} catch (java.text.ParseException e) { valid = false; }

Try / catch

try {
    Integer node = partitionByDate.calculate(columnValue);
} catch (IllegalArgumentException e) {
    // log columnValue and configured dateFormat, reject row client-side
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of MyCATApache/Mycat-Server@65f8d8beb7 (2026-09-11). Data as JSON: /api/errors/9aebf8e1d58b350c. Report an issue: GitHub.

Appendix: source

Thrown at src/main/java/io/mycat/route/function/PartitionByDate.java:94

	@Override
	public Integer calculate(String columnValue)  {
		try {
			int targetPartition ;
			if(bNaturalDay){
				Calendar curTime = Calendar.getInstance();
				curTime.setTime(formatter.get().parse(columnValue));
				targetPartition = curTime.get(Calendar.DAY_OF_MONTH);
				return  targetPartition-1;
			}
			long targetTime = formatter.get().parse(columnValue).getTime();
			targetPartition = (int) ((targetTime - beginDate) / partionTime);
			if(targetTime>endDate && nCount!=0) {
				targetPartition = targetPartition % nCount;
			}
			return targetPartition;

		} catch (ParseException e) {
			throw new IllegalArgumentException(new StringBuilder().append("columnValue:").append(columnValue).append(" Please check if the format satisfied.").toString(),e);
		}
	}

	@Override
	public Integer[] calculateRange(String beginValue, String endValue)  {
		SimpleDateFormat format = new SimpleDateFormat(this.dateFormat);
		try {
			Date beginDate = format.parse(beginValue);
			Date endDate = format.parse(endValue);
			Calendar cal = Calendar.getInstance();
			List<Integer> list = new ArrayList<Integer>();
			while(beginDate.getTime() <= endDate.getTime()){
				Integer nodeValue = this.calculate(format.format(beginDate));
				if(Collections.frequency(list, nodeValue) < 1) list.add(nodeValue);
				cal.setTime(beginDate);
				cal.add(Calendar.DATE, 1);
				beginDate = cal.getTime();
			}

View on GitHub (pinned to 65f8d8beb7)