{"record":{"id":"da7fcad569d4d181","repo":"apache/seatunnel","slug":"cannot-convert-timestamp-type","errorCode":null,"errorMessage":"Cannot convert timestamp: , type: ","messagePattern":"Cannot convert timestamp: , type: ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-iceberg/src/main/java/org/apache/seatunnel/connectors/seatunnel/iceberg/data/RowConverter.java","lineNumber":468,"sourceCode":"            return LocalDateTime.parse(tsStr, DateTimeFormatter.ISO_LOCAL_DATE_TIME)\n                    .atOffset(ZoneOffset.UTC);\n        }\n    }\n\n    private LocalDateTime convertLocalDateTime(Object value) {\n        if (value instanceof Number) {\n            long millis = ((Number) value).longValue();\n            return DateTimeUtil.timestampFromMicros(millis * 1000);\n        } else if (value instanceof String) {\n            return parseLocalDateTime((String) value);\n        } else if (value instanceof LocalDateTime) {\n            return (LocalDateTime) value;\n        } else if (value instanceof OffsetDateTime) {\n            return ((OffsetDateTime) value).toLocalDateTime();\n        } else if (value instanceof Date) {\n            return DateTimeUtil.timestampFromMicros(((Date) value).getTime() * 1000);\n        }\n        throw new RuntimeException(\n                \"Cannot convert timestamp: \" + value + \", type: \" + value.getClass());\n    }\n\n    private LocalDateTime parseLocalDateTime(String str) {\n        String tsStr = ensureTimestampFormat(str);\n        try {\n            return LocalDateTime.parse(tsStr, DateTimeFormatter.ISO_LOCAL_DATE_TIME);\n        } catch (DateTimeParseException e) {\n            return OFFSET_TS_FMT.parse(tsStr, OffsetDateTime::from).toLocalDateTime();\n        }\n    }\n\n    private String ensureTimestampFormat(String str) {\n        String result = str;\n        if (result.charAt(10) == ' ') {\n            result = result.substring(0, 10) + 'T' + result.substring(11);\n        }\n        if (result.length() > 22 && result.charAt(19) == '+' && result.charAt(22) == ':') {","sourceCodeStart":450,"sourceCodeEnd":486,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-iceberg/src/main/java/org/apache/seatunnel/connectors/seatunnel/iceberg/data/RowConverter.java#L450-L486","documentation":"Iceberg RowConverter throws this RuntimeException when a non-UTC timestamp (Iceberg TimestampType without UTC adjustment) value cannot be converted to LocalDateTime. convertLocalDateTime accepts String, LocalDateTime, OffsetDateTime, and Date; anything else is rejected with the value and its class in the message.","triggerScenarios":"convertLocalDateTime receives an unsupported object (e.g. Long, ZonedDateTime, Instant) while converting a field for a plain (non-timestamptz) Iceberg timestamp column via convertTimestampValue.","commonSituations":"Sources emitting Instant/ZonedDateTime for timestamp columns; epoch-seconds Long values from JSON/CDC sources; schema changes altered the column type upstream.","solutions":["Convert the value to LocalDateTime or java.util.Date before the sink.","Add a transform CAST(column, TIMESTAMP) to deliver a supported type.","For Instants: LocalDateTime.ofInstant(instant, ZoneId.systemDefault()).","Configure the source so timestamps map to SeaTunnel TimestampType (LocalDateTime-backed)."],"exampleFix":"// before\nwriter.write(idx, Instant.now()); // Instant not accepted\n// after\nwriter.write(idx, LocalDateTime.ofInstant(Instant.now(), ZoneId.systemDefault())); // LocalDateTime accepted","handlingStrategy":"type-guard","validationCode":"if (!(v instanceof LocalDateTime) && !(v instanceof OffsetDateTime) && !(v instanceof java.util.Date) && !(v instanceof String)) throw new IllegalArgumentException(\"timestamp column must be LocalDateTime/OffsetDateTime/Date/String, got \" + (v == null ? \"null\" : v.getClass().getName()));","typeGuard":"boolean isTimestampConvertible(Object v) { return v instanceof LocalDateTime || v instanceof OffsetDateTime || v instanceof java.util.Date || v instanceof String; }","tryCatchPattern":"try { sink.write(row); } catch (RuntimeException e) { if (e.getMessage() != null && e.getMessage().startsWith(\"Cannot convert timestamp\")) { /* convert Instant/ZonedDateTime or DLQ */ } else throw e; }","preventionTips":["Convert Instant/ZonedDateTime to LocalDateTime before the sink","CAST timestamp columns to SeaTunnel TimestampType in transforms","Keep source and sink temporal types aligned in schema definitions"],"tags":["iceberg","type-conversion","timestamp","sink"],"backgroundTag":"type-mismatch","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}