{"record":{"id":"3438be97a84e8646","repo":"alibaba/DataX","slug":"date-s-3438be","errorCode":null,"errorMessage":"Date 类型转换错误：[%s]","messagePattern":"Date 类型转换错误：\\[(.+?)\\]","errorType":"exception","errorClass":"SQLException","httpStatus":null,"severity":"error","filePath":"clickhousewriter/src/main/java/com/alibaba/datax/plugin/writer/clickhousewriter/ClickhouseWriter.java","lineNumber":140,"sourceCode":"\t\t\t\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase Types.DATE:\n\t\t\t\t\t\t\t\tif (this.resultSetMetaData.getRight().get(columnIndex)\n\t\t\t\t\t\t\t\t\t\t.equalsIgnoreCase(\"year\")) {\n\t\t\t\t\t\t\t\t\tif (column.asBigInteger() == null) {\n\t\t\t\t\t\t\t\t\t\tpreparedStatement.setString(columnIndex + 1, null);\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\tpreparedStatement.setInt(columnIndex + 1, column.asBigInteger().intValue());\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tjava.sql.Date sqlDate = null;\n\t\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\t\tutilDate = column.asDate();\n\t\t\t\t\t\t\t\t\t} catch (DataXException e) {\n\t\t\t\t\t\t\t\t\t\tthrow new SQLException(String.format(\n\t\t\t\t\t\t\t\t\t\t\t\t\"Date 类型转换错误：[%s]\", column));\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\tif (null != utilDate) {\n\t\t\t\t\t\t\t\t\t\tsqlDate = new java.sql.Date(utilDate.getTime());\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tpreparedStatement.setDate(columnIndex + 1, sqlDate);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase Types.TIME:\n\t\t\t\t\t\t\t\tjava.sql.Time sqlTime = null;\n\t\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\t\tutilDate = column.asDate();\n\t\t\t\t\t\t\t\t} catch (DataXException e) {\n\t\t\t\t\t\t\t\t\tthrow new SQLException(String.format(\n\t\t\t\t\t\t\t\t\t\t\t\"Date 类型转换错误：[%s]\", column));\n\t\t\t\t\t\t\t\t}","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/alibaba/DataX/blob/80ec23d5c5328eb90ca364d2749e92dfaf44541e/clickhousewriter/src/main/java/com/alibaba/datax/plugin/writer/clickhousewriter/ClickhouseWriter.java#L122-L158","documentation":"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.","triggerScenarios":"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'.","commonSituations":"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.","solutions":["Check the failing row/column index (enable writer debug logs) and inspect the source value for the DATE column","Fix the source data or convert it to a real date type in the reader so asDate() succeeds","Align the writer column list/order with the ClickHouse table schema so date values land in DATE columns","Clean or filter rows with unparseable date strings before the write"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"catch (SQLException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"Date 类型转换错误\")) {\n    // identify the failing row/column from batch context; fix source data or column mapping\n  }\n  throw e;\n}","preventionTips":["Keep reader column types aligned with the ClickHouse table's Date columns","Convert string dates to real date types upstream","Log row primary keys per batch so failing rows are identifiable"],"tags":["clickhousewriter","date-conversion","type-mismatch","data-quality"],"backgroundTag":null,"analyzedSha":"80ec23d5c5328eb90ca364d2749e92dfaf44541e","analyzedAt":"2026-08-14T15:33:51.187Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}