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

PartitionByHotDate.calculate() parses the column value as a date (SimpleDateFormat) to compute a 'hot' time-based partition. On ParseException it throws this IllegalArgumentException with the offending columnValue. The value's format does not match the configured date format.

Solutions

  1. Align dateFormat property with the actual format of the column values.
  2. Normalize the value before insert (e.g. strip time or reformat) in the application.
  3. Catch IllegalArgumentException in the SQL path and surface a clear client-side validation error.

Example fix

// before (rule dateFormat yyyy-MM-dd, data with time)
INSERT INTO t(id, dt) VALUES(1, '2024-01-01 10:00:00');
// after
INSERT INTO t(id, dt) 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 = partitionByHotDate.calculate(columnValue);
} catch (IllegalArgumentException e) {
    // inspect offending value logged inside the message
}

Prevention

When it happens

Trigger: calculate() receiving a column value that fails parsing: wrong date pattern vs dateFormat config, empty string, garbage text, or timestamp format differing from expectation; reached via calculateRange() and test() as well.

Common situations: Applications inserting 'yyyy-MM-dd HH:mm:ss' while the rule expects 'yyyy-MM-dd' (or vice versa); nulls converted to string 'null'; regional date orders (dd/MM vs MM/dd).

Related errors


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

Appendix: source

Thrown at src/main/java/io/mycat/route/function/PartitionByHotDate.java:81

		Integer targetPartition = -1;
		try {
			long targetTime = formatter.get().parse(columnValue).getTime();
			Calendar now = Calendar.getInstance();
			long nowTime = now.getTimeInMillis();
			
			beginDate = nowTime - sLastTime * oneDay;
			
			long diffDays = (nowTime - targetTime) / (1000 * 60 * 60 * 24) + 1;
			if(diffDays-sLastTime <= 0 || diffDays<0 ){
				targetPartition = 0;
			}else{
				targetPartition = (int) ((beginDate - targetTime) / partionTime) + 1;
			}
			
		    LOGGER.debug("PartitionByHotDate calculate for " + columnValue + " return " + targetPartition);
			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)  {
		Integer[] targetPartition = null;
		try {
			long startTime = formatter.get().parse(beginValue).getTime();
			long endTime = formatter.get().parse(endValue).getTime();
			Calendar now = Calendar.getInstance();
			long nowTime = now.getTimeInMillis();
			
			long limitDate = nowTime - sLastTime * oneDay;
			long diffDays = (nowTime - startTime) / (1000 * 60 * 60 * 24) + 1;
			if(diffDays-sLastTime <= 0 || diffDays<0 ){
				Integer [] re = new Integer[1];
				re[0] = 0;
				targetPartition = re ;

View on GitHub (pinned to 65f8d8beb7)