alibaba/DataX · error · SQLException

Date 类型转换错误:[%s]

Error message

Date 类型转换错误:[%s]

What it means

Thrown in ClickhouseWriter's DATE branch when Column.asDate() raises a DataXException — i.e. the incoming Column object cannot be converted to a java.util.Date. The writer catches DataXException and rethrows it as SQLException with this message, which typically aborts the batch write. Note the 'year' ClickHouse type bypasses this path and reads as integer.

Source

Thrown at clickhousewriter/src/main/java/com/alibaba/datax/plugin/writer/clickhousewriter/ClickhouseWriter.java:140

											break;
									}
								}
								break;

							case Types.DATE:
								if (this.resultSetMetaData.getRight().get(columnIndex)
										.equalsIgnoreCase("year")) {
									if (column.asBigInteger() == null) {
										preparedStatement.setString(columnIndex + 1, null);
									} else {
										preparedStatement.setInt(columnIndex + 1, column.asBigInteger().intValue());
									}
								} else {
									java.sql.Date sqlDate = null;
									try {
										utilDate = column.asDate();
									} catch (DataXException e) {
										throw new SQLException(String.format(
												"Date 类型转换错误:[%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 类型转换错误:[%s]", column));
								}

View on GitHub (pinned to 80ec23d5c5)

Solutions

  1. Check the failing row/column index (enable writer debug logs) and inspect the source value for the DATE column
  2. Fix the source data or convert it to a real date type in the reader so asDate() succeeds
  3. Align the writer column list/order with the ClickHouse table schema so date values land in DATE columns
  4. Clean or filter rows with unparseable date strings before the write
Defensive patterns

Strategy: try-catch

Try / catch

catch (SQLException e) {
  if (e.getMessage() != null && e.getMessage().contains("Date 类型转换错误")) {
    // identify the failing row/column from batch context; fix source data or column mapping
  }
  throw e;
}

Prevention

When it happens

Trigger: Filling a prepared statement for a column of java.sql.Types.DATE whose Column (e.g. a StringColumn or LongColumn holding a non-date value) fails asDate() conversion; the target column type is not 'year'.

Common situations: Reader column is a string that is not parseable as a date while the ClickHouse target column is Date; type mismatch between source column type and the DATE slot in the writer's insert; dirty data such as empty strings or numeric codes in a date field.

Related errors


AI-assisted analysis of alibaba/DataX@80ec23d5c5 (2026-08-14). Data as JSON: /api/errors/3438be97a84e8646. Report an issue: GitHub.