alibaba/DataX · error · Exception
DATE类型数据 '%s' 格式不正确,必须为yyyy-mm-dd格式
Error message
DATE类型数据 '%s' 格式不正确,必须为yyyy-mm-dd格式
What it means
Thrown by CassandraWriterHelper's string-to-value converter for DATE columns. It expects a strict yyyy-mm-dd literal (exactly two '-' separators after split), and anything else — '2024/01/02', '2024-1-2', empty fragments, or a full timestamp — fails the a.length != 3 check. The message names the offending value and the required format.
Source
Thrown at cassandrawriter/src/main/java/com/alibaba/datax/plugin/writer/cassandrawriter/CassandraWriterHelper.java:102
case BIGINT:
return Long.valueOf(s);
case VARINT:
return new BigInteger(s, 10);
case FLOAT:
return Float.valueOf(s);
case DOUBLE:
return Double.valueOf(s);
case DECIMAL:
return new BigDecimal(s);
case DATE: {
String[] a = s.split("-");
if (a.length != 3) {
throw new Exception(String.format("DATE类型数据 '%s' 格式不正确,必须为yyyy-mm-dd格式", s));
}
return LocalDate.fromYearMonthDay(Integer.valueOf(a[0]), Integer.valueOf(a[1]),
Integer.valueOf(a[2]));
}
case TIME:
return Long.valueOf(s);
case TIMESTAMP:
return new Date(Long.valueOf(s));
case UUID:
case TIMEUUID:
return UUID.fromString(s);
case INET:
String[] b = s.split("/");
if (b.length < 2) {View on GitHub (pinned to 80ec23d5c5)
Solutions
- Normalize the source value to yyyy-mm-dd before it reaches cassandrawriter (convert in the reader or via a transform)
- If the data is really a timestamp, change the Cassandra column/writer type mapping to TIMESTAMP instead of DATE
- Fix malformed rows in the source data (wrong separators, missing parts)
Example fix
// before
{"name": "cassandrawriter", "parameter": {"column": [{"name": "d", "type": "DATE"}]}}
// source value: "2024/12/01" -> throws
// after: convert source to "2024-12-01" (yyyy-mm-dd) or declare the column as TIMESTAMP Defensive patterns
Strategy: validation
Validate before calling
// normalize before writing DATE columns
static String toIsoDate(String s) {
String[] a = s.split("-");
if (a.length != 3) throw new IllegalArgumentException("Not yyyy-mm-dd: " + s);
return String.format("%04d-%02d-%02d", Integer.valueOf(a[0].trim()), Integer.valueOf(a[1].trim()), Integer.valueOf(a[2].trim()));
} Type guard
boolean isYyyyMmDd(String s) {
return s != null && s.split("-").length == 3
&& s.matches("\\d{1,4}-\\d{1,2}-\\d{1,2}");
} Try / catch
catch (Exception e) {
if (e.getMessage() != null && e.getMessage().contains("yyyy-mm-dd")) {
// route the row to a dirty-data sink or fix the source format
}
throw e;
} Prevention
- Emit dates from the reader as Date objects or ISO yyyy-mm-dd strings
- Use TIMESTAMP mapping when source values carry time components
- Profile source date formats before configuring Cassandra DATE columns
When it happens
Trigger: A cassandrawriter column of CQL type DATE whose incoming string does not split on '-' into exactly 3 parts, e.g. '2024/12/01', '2024-12-01 00:00:00', or '2024-12'.
Common situations: Reader emitting timestamps or localized date strings into a DATE column; column configuration declaring a DATE type for data that is actually a timestamp; hand-written test data with mixed separators or missing zero-padding is fine ('2024-1-2' still splits to 3) but any format with != 3 dash-separated parts throws.
Related errors
- Date 类型转换错误:[%s]
- Date type conversion error: [%s]
- Unknown column type:
- Failed to flush data to Doris. %s
AI-assisted analysis of alibaba/DataX@80ec23d5c5 (2026-08-14).
Data as JSON: /api/errors/bb03c4d17a35ebca.
Report an issue: GitHub.