alibaba/DataX · error · SQLException
Date type conversion error
Error message
Date type conversion error: [%s]
What it means
DatabendWriter throws this SQLException when writing a column whose JDBC type is DATE and column.asDate() raises a DataXException — i.e. the incoming Column cannot be interpreted as a date at all. The failed column object itself is embedded in the message, and the exception propagates out of the PreparedStatement population loop, failing the write batch.
Solutions
- Inspect the failed column in the message (Column.toString includes type and value) to find the offending row.
- Fix or transform the source data: use a transformer (dx_replace/dx_substr) or clean the string to a supported date format before it reaches the writer.
- Cast the Databend column to a string type if the source genuinely contains non-date values.
- Verify the reader's column type mapping so date-like sources arrive as DateColumn rather than StringColumn.
Example fix
// before: reader passes "2021-13-45" into a DATE column -> SQLException
// after: validate/normalize in a transformer or reader query
"transformer": [{ "name": "dx_replace", "parameter": { "columnIndex": 3, "paras": [3, "8", "2", "01"] } }]
// or exclude/clean bad rows at the source query level Defensive patterns
Strategy: validation
Validate before calling
// reader-side guard: only pass values that asDate() can handle
Object v = record.getColumn(i).getRawValue();
if (v instanceof String && !v.toString().matches("\\d{4}-\\d{2}-\\d{2}.*")) {
throw new IllegalArgumentException("Row " + record + ": column " + i + " is not a date: " + v);
} Try / catch
catch (SQLException e) { if (e.getMessage().contains("Date type conversion error")) { log offending batch/row from message-embedded Column; dirty-route the record } else throw e; } Prevention
- Match Databend DATE columns to source columns that emit DateColumn.
- Add a pre-write data-quality pass rejecting non-date strings for date targets.
When it happens
Trigger: A DATE-typed target column receiving a Column subtype whose asDate() throws — typically a StringColumn holding a non-date string like "N/A" or "2021-13-45", or a numeric column with an out-of-range raw value. Unlike TIMESTAMP, there is no regex fast-path for DATE; conversion goes straight to asDate().
Common situations: Source column typed as string containing free text or a different date format, dirty rows after an upstream schema change, or null handling differences where asString() is null but the column is a type that cannot produce a Date.
Related errors
- Failed to create row serializer, unsupported `format` from…
- Failed to flush data to Doris, Error could not get the…
- Failed to flush data to Doris.
- Failed to parse delimiter: `Hex str format error`
- Failed to parse delimiter: `Hex str is empty`
AI-assisted analysis of alibaba/DataX@80ec23d5c5 (2026-08-14).
Data as JSON: /api/errors/4f87fd4ebdee450a.
Report an issue: GitHub.
Appendix: source
Thrown at databendwriter/src/main/java/com/alibaba/datax/plugin/writer/databendwriter/DatabendWriter.java:112
case Types.BIGINT:
preparedStatement.setLong(columnIndex + 1, column.asLong());
break;
case Types.DECIMAL:
preparedStatement.setBigDecimal(columnIndex + 1, column.asBigDecimal());
break;
case Types.FLOAT:
case Types.REAL:
preparedStatement.setFloat(columnIndex + 1, column.asDouble().floatValue());
break;
case Types.DOUBLE:
preparedStatement.setDouble(columnIndex + 1, column.asDouble());
break;
case Types.DATE:
java.sql.Date sqlDate = null;
try {
utilDate = column.asDate();
} catch (DataXException e) {
throw new SQLException(String.format(
"Date type conversion error: [%s]", column));
}
if (null != utilDate) {
sqlDate = new java.sql.Date(utilDate.getTime());
}
preparedStatement.setDate(columnIndex + 1, sqlDate);
break;
case Types.TIME:
java.sql.Time sqlTime = null;
try {
utilDate = column.asDate();
} catch (DataXException e) {
throw new SQLException(String.format(
"Date type conversion error: [%s]", column));
}
View on GitHub (pinned to 80ec23d5c5)