{"record":{"id":"4f87fd4ebdee450a","repo":"alibaba/DataX","slug":"date-type-conversion-error-s","errorCode":null,"errorMessage":"Date type conversion error: [%s]","messagePattern":"Date type conversion error: \\[(.+?)\\]","errorType":"exception","errorClass":"SQLException","httpStatus":null,"severity":"error","filePath":"databendwriter/src/main/java/com/alibaba/datax/plugin/writer/databendwriter/DatabendWriter.java","lineNumber":112,"sourceCode":"                            case Types.BIGINT:\n                                preparedStatement.setLong(columnIndex + 1, column.asLong());\n                                break;\n                            case Types.DECIMAL:\n                                preparedStatement.setBigDecimal(columnIndex + 1, column.asBigDecimal());\n                                break;\n                            case Types.FLOAT:\n                            case Types.REAL:\n                                preparedStatement.setFloat(columnIndex + 1, column.asDouble().floatValue());\n                                break;\n                            case Types.DOUBLE:\n                                preparedStatement.setDouble(columnIndex + 1, column.asDouble());\n                                break;\n                            case Types.DATE:\n                                java.sql.Date sqlDate = null;\n                                try {\n                                    utilDate = column.asDate();\n                                } catch (DataXException e) {\n                                    throw new SQLException(String.format(\n                                            \"Date type conversion error: [%s]\", column));\n                                }\n\n                                if (null != utilDate) {\n                                    sqlDate = new java.sql.Date(utilDate.getTime());\n                                }\n                                preparedStatement.setDate(columnIndex + 1, sqlDate);\n                                break;\n\n                            case Types.TIME:\n                                java.sql.Time sqlTime = null;\n                                try {\n                                    utilDate = column.asDate();\n                                } catch (DataXException e) {\n                                    throw new SQLException(String.format(\n                                            \"Date type conversion error: [%s]\", column));\n                                }\n","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/alibaba/DataX/blob/80ec23d5c5328eb90ca364d2749e92dfaf44541e/databendwriter/src/main/java/com/alibaba/datax/plugin/writer/databendwriter/DatabendWriter.java#L94-L130","documentation":"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.","triggerScenarios":"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().","commonSituations":"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.","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."],"exampleFix":"// before: reader passes \"2021-13-45\" into a DATE column -> SQLException\n// after: validate/normalize in a transformer or reader query\n\"transformer\": [{ \"name\": \"dx_replace\", \"parameter\": { \"columnIndex\": 3, \"paras\": [3, \"8\", \"2\", \"01\"] } }]\n// or exclude/clean bad rows at the source query level","handlingStrategy":"validation","validationCode":"// reader-side guard: only pass values that asDate() can handle\nObject v = record.getColumn(i).getRawValue();\nif (v instanceof String && !v.toString().matches(\"\\\\d{4}-\\\\d{2}-\\\\d{2}.*\")) {\n    throw new IllegalArgumentException(\"Row \" + record + \": column \" + i + \" is not a date: \" + v);\n}","typeGuard":null,"tryCatchPattern":"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; }","preventionTips":["Match Databend DATE columns to source columns that emit DateColumn.","Add a pre-write data-quality pass rejecting non-date strings for date targets."],"tags":["datax","databend","writer","type-conversion","date"],"backgroundTag":null,"analyzedSha":"80ec23d5c5328eb90ca364d2749e92dfaf44541e","analyzedAt":"2026-08-14T15:33:51.187Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}