apache/seatunnel · error · RuntimeException
Cannot convert timestamp: , type:
Error message
Cannot convert timestamp: , type:
What it means
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.
Source
Thrown at seatunnel-connectors-v2/connector-iceberg/src/main/java/org/apache/seatunnel/connectors/seatunnel/iceberg/data/RowConverter.java:468
return LocalDateTime.parse(tsStr, DateTimeFormatter.ISO_LOCAL_DATE_TIME)
.atOffset(ZoneOffset.UTC);
}
}
private LocalDateTime convertLocalDateTime(Object value) {
if (value instanceof Number) {
long millis = ((Number) value).longValue();
return DateTimeUtil.timestampFromMicros(millis * 1000);
} else if (value instanceof String) {
return parseLocalDateTime((String) value);
} else if (value instanceof LocalDateTime) {
return (LocalDateTime) value;
} else if (value instanceof OffsetDateTime) {
return ((OffsetDateTime) value).toLocalDateTime();
} else if (value instanceof Date) {
return DateTimeUtil.timestampFromMicros(((Date) value).getTime() * 1000);
}
throw new RuntimeException(
"Cannot convert timestamp: " + value + ", type: " + value.getClass());
}
private LocalDateTime parseLocalDateTime(String str) {
String tsStr = ensureTimestampFormat(str);
try {
return LocalDateTime.parse(tsStr, DateTimeFormatter.ISO_LOCAL_DATE_TIME);
} catch (DateTimeParseException e) {
return OFFSET_TS_FMT.parse(tsStr, OffsetDateTime::from).toLocalDateTime();
}
}
private String ensureTimestampFormat(String str) {
String result = str;
if (result.charAt(10) == ' ') {
result = result.substring(0, 10) + 'T' + result.substring(11);
}
if (result.length() > 22 && result.charAt(19) == '+' && result.charAt(22) == ':') {View on GitHub (pinned to cf67b549a7)
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).
Example fix
// before writer.write(idx, Instant.now()); // Instant not accepted // after writer.write(idx, LocalDateTime.ofInstant(Instant.now(), ZoneId.systemDefault())); // LocalDateTime accepted
Defensive patterns
Strategy: type-guard
Validate before calling
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())); Type guard
boolean isTimestampConvertible(Object v) { return v instanceof LocalDateTime || v instanceof OffsetDateTime || v instanceof java.util.Date || v instanceof String; } Try / catch
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; } Prevention
- 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
When it happens
Trigger: convertLocalDateTime receives an unsupported object (e.g. Long, ZonedDateTime, Instant) while converting a field for a plain (non-timestamptz) Iceberg timestamp column via convertTimestampValue.
Common situations: Sources emitting Instant/ZonedDateTime for timestamp columns; epoch-seconds Long values from JSON/CDC sources; schema changes altered the column type upstream.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- Cannot convert to BigDecimal:
- Cannot convert to boolean:
- Cannot convert to UUID:
- Cannot convert to binary:
- Cannot convert date:
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/da7fcad569d4d181.
Report an issue: GitHub.