{"record":{"id":"39ecf5d566322de7","repo":"apache/seatunnel","slug":"unsupported-date-unit","errorCode":null,"errorMessage":"Unsupported Date unit: ","messagePattern":"Unsupported Date unit: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-lance/src/main/java/org/apache/seatunnel/connectors/seatunnel/lance/sink/writers/DateTypeWriter.java","lineNumber":49,"sourceCode":"\n/** Writer for Date type. */\npublic class DateTypeWriter extends BaseTypeWriter {\n    @Override\n    public void writeToVector(\n            FieldVector vector,\n            ArrowType arrowType,\n            Object value,\n            int rowIndex,\n            BufferAllocator allocator) {\n        ArrowType.Date dateType = (ArrowType.Date) arrowType;\n        if (dateType.getUnit() == DateUnit.DAY) {\n            long epochDay = convertToEpochDay(value);\n            ((DateDayVector) vector).setSafe(rowIndex, (int) epochDay);\n        } else if (dateType.getUnit() == DateUnit.MILLISECOND) {\n            long epochMilli = convertToEpochMilli(value);\n            ((DateMilliVector) vector).setSafe(rowIndex, epochMilli);\n        } else {\n            throw new IllegalArgumentException(\"Unsupported Date unit: \" + dateType.getUnit());\n        }\n    }\n\n    private long convertToEpochDay(Object value) {\n        if (value instanceof LocalDate) {\n            return ((LocalDate) value).toEpochDay();\n        } else if (value instanceof java.sql.Date) {\n            return ((java.sql.Date) value).toLocalDate().toEpochDay();\n        } else {\n            return LocalDate.parse(value.toString()).toEpochDay();\n        }\n    }\n\n    private long convertToEpochMilli(Object value) {\n        if (value instanceof LocalDate) {\n            return ((LocalDate) value)\n                    .atStartOfDay(ZoneId.systemDefault())\n                    .toInstant()","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-lance/src/main/java/org/apache/seatunnel/connectors/seatunnel/lance/sink/writers/DateTypeWriter.java#L31-L67","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nnew ArrowType.Date(DateUnit.SECOND) // invalid unit\n// after\nnew ArrowType.Date(DateUnit.MILLISECOND)","handlingStrategy":"validation","validationCode":"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\");","typeGuard":null,"tryCatchPattern":"try { writer.write(row); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith(\"Unsupported Date unit\")) { /* rebuild schema with DAY/MILLISECOND */ } throw e; }","preventionTips":["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."],"tags":["lance","arrow","date","enum"],"backgroundTag":"unsupported-enum-value","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"}