apache/seatunnel · error · IllegalArgumentException
Unsupported Date unit:
Error message
Unsupported Date unit:
What it means
DateTypeWriter.writeToVector writes to DateDayVector or DateMilliVector depending on the Arrow DateType unit. Arrow only defines DAY and MILLISECOND units, so this guard fires only if an unknown/future DateUnit appears, and throws IllegalArgumentException. It means the field's Arrow date unit is not one the writer knows how to handle.
Source
Thrown at seatunnel-connectors-v2/connector-lance/src/main/java/org/apache/seatunnel/connectors/seatunnel/lance/sink/writers/DateTypeWriter.java:49
/** Writer for Date type. */
public class DateTypeWriter extends BaseTypeWriter {
@Override
public void writeToVector(
FieldVector vector,
ArrowType arrowType,
Object value,
int rowIndex,
BufferAllocator allocator) {
ArrowType.Date dateType = (ArrowType.Date) arrowType;
if (dateType.getUnit() == DateUnit.DAY) {
long epochDay = convertToEpochDay(value);
((DateDayVector) vector).setSafe(rowIndex, (int) epochDay);
} else if (dateType.getUnit() == DateUnit.MILLISECOND) {
long epochMilli = convertToEpochMilli(value);
((DateMilliVector) vector).setSafe(rowIndex, epochMilli);
} else {
throw new IllegalArgumentException("Unsupported Date unit: " + dateType.getUnit());
}
}
private long convertToEpochDay(Object value) {
if (value instanceof LocalDate) {
return ((LocalDate) value).toEpochDay();
} else if (value instanceof java.sql.Date) {
return ((java.sql.Date) value).toLocalDate().toEpochDay();
} else {
return LocalDate.parse(value.toString()).toEpochDay();
}
}
private long convertToEpochMilli(Object value) {
if (value instanceof LocalDate) {
return ((LocalDate) value)
.atStartOfDay(ZoneId.systemDefault())
.toInstant()View on GitHub (pinned to cf67b549a7)
Solutions
- Use standard Arrow DateUnits: DateUnit.DAY or DateUnit.MILLISECOND in the schema.
- Upgrade the SeaTunnel lance connector (and its lance/arrow SDK) if a newer Arrow version introduced new units.
- Pre-normalize date columns to DateUnit.DAY in any custom schema conversion code feeding this writer.
Example fix
// before new ArrowType.Date(DateUnit.SECOND) // invalid unit // after new ArrowType.Date(DateUnit.MILLISECOND)
Defensive patterns
Strategy: validation
Validate before calling
ArrowType t = field.getType(); if (t instanceof ArrowType.Date && ((ArrowType.Date) t).getUnit() != DateUnit.DAY && ((ArrowType.Date) t).getUnit() != DateUnit.MILLISECOND) throw new IllegalArgumentException("unsupported date unit"); Try / catch
try { writer.write(row); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith("Unsupported Date unit")) { /* rebuild schema with DAY/MILLISECOND */ } throw e; } Prevention
- Only use DateUnit.DAY or DateUnit.MILLISECOND when defining Arrow schemas.
- Keep lance/arrow SDK and connector versions aligned.
- Validate generated schemas in unit tests before deployment.
When it happens
Trigger: writeToVector is called with an ArrowType.Date whose getUnit() is neither DAY nor MILLISECOND — practically only with a nonstandard/extended Arrow build or a manually constructed ArrowType with a bogus unit.
Common situations: Custom schema construction or a Lance/Arrow version introducing a new DateUnit that this connector version does not know; hand-built Arrow schemas in tests using an invalid unit.
Related errors
- Unsupported date value type:
- TABLE_DATASET_WRITE_ST_ROW_EXCEPTION
- Unsupported timestamp value type:
- Unsupported FloatingPoint precision:
- Unsupported Int bit width:
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/39ecf5d566322de7.
Report an issue: GitHub.