{"record":{"id":"e6c78e35a2b8577c","repo":"apache/seatunnel","slug":"unsupported-timestamp-unit-unit","errorCode":null,"errorMessage":"Unsupported Timestamp unit: ${unit}","messagePattern":"Unsupported Timestamp unit: (.+?)","errorType":"exception","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-lance/src/main/java/org/apache/seatunnel/connectors/seatunnel/lance/sink/writers/TimestampTypeWriter.java","lineNumber":58,"sourceCode":"        long epochMicro = convertToEpochMicro(value);\n        TimeUnit unit = timestampType.getUnit();\n        String timezone = timestampType.getTimezone();\n\n        if (unit == TimeUnit.MICROSECOND) {\n            if (timezone != null && !timezone.isEmpty()) {\n                ((TimeStampMicroTZVector) vector).setSafe(rowIndex, epochMicro);\n            } else {\n                ((TimeStampMicroVector) vector).setSafe(rowIndex, epochMicro);\n            }\n        } else if (unit == TimeUnit.MILLISECOND) {\n            long epochMilli = epochMicro / 1000;\n            if (timezone != null && !timezone.isEmpty()) {\n                ((TimeStampMilliTZVector) vector).setSafe(rowIndex, epochMilli);\n            } else {\n                ((TimeStampMilliVector) vector).setSafe(rowIndex, epochMilli);\n            }\n        } else {\n            throw new IllegalArgumentException(\"Unsupported Timestamp unit: \" + unit);\n        }\n    }\n\n    @Override\n    public void writeToListWriter(\n            UnionListWriter writer, ArrowType arrowType, Object value, BufferAllocator allocator) {\n        ArrowType.Timestamp timestampType = (ArrowType.Timestamp) arrowType;\n        long epochMicro = convertToEpochMicro(value);\n        TimeUnit unit = timestampType.getUnit();\n        if (unit == TimeUnit.MICROSECOND) {\n            writer.writeTimeStampMicro(epochMicro);\n        } else if (unit == TimeUnit.MILLISECOND) {\n            writer.writeTimeStampMilli(epochMicro / 1000);\n        }\n    }\n\n    @Override\n    public void writeToMapKey(","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-lance/src/main/java/org/apache/seatunnel/connectors/seatunnel/lance/sink/writers/TimestampTypeWriter.java#L40-L76","documentation":"TimestampTypeWriter.writeToVector only handles the Arrow timestamp units it explicitly implements (SEC/MILLI etc.); any other TimeStamp unit (e.g. MICRO, NANO with an unhandled branch) falls through to this IllegalArgumentException. The unit comes from the Arrow field's TimeStamp type, which is derived from the declared SeaTunnel schema/column type.","triggerScenarios":"A Lance sink column resolves to an Arrow TimeStamp with a unit not covered by the if/else chain in writeToVector — e.g. TIMESTAMP with nanosecond or microsecond precision mapped to an Arrow TimeStampUnit the writer lacks a branch for.","commonSituations":"Source data with micro/nano precision timestamps (e.g. from protobuf, pandas, or JDBC) where schema translation picks a finer Arrow unit than the writer supports; timezone-aware timestamp columns interacting with unit selection.","solutions":["Coerce the column to millisecond precision in the pipeline (e.g. cast timestamp to TIMESTAMP(3)) so Arrow uses TimeStampMilli, which is supported.","Check which Arrow TimeStampUnit the field has (print field.getType()) and confirm it is one the writer handles (SECOND/MILLI).","Add a branch for the missing unit (TimeStampMicroVector / TimeStampNanoVector with setSafe of the corresponding epoch value) if you maintain a fork.","Verify the source-to-SeaTunnel type mapping isn't silently producing TIMESTAMP(6)/(9); cast at the source instead."],"exampleFix":"// before: nano-precision column\ncolumns = \"ts timestamp(9)\"\n\n// after: millisecond precision\ncolumns = \"ts timestamp(3)\"  // maps to supported TimeStampMilli","handlingStrategy":"validation","validationCode":"// Java: verify the arrow timestamp unit before writing\nArrowType t = field.getType();\nif (t instanceof ArrowType.Timestamp) {\n    ArrowType.Timestamp ts = (ArrowType.Timestamp) t;\n    if (ts.getUnit() != ArrowType.TimestampUnit.SECOND\n            && ts.getUnit() != ArrowType.TimestampUnit.MILLISECOND) {\n        throw new IllegalArgumentException(\"Unsupported unit: \" + ts.getUnit());\n    }\n}","typeGuard":"boolean isSupportedTimestamp(ArrowType t) {\n    if (!(t instanceof ArrowType.Timestamp)) return false;\n    ArrowType.TimestampUnit u = ((ArrowType.Timestamp) t).getUnit();\n    return u == ArrowType.TimestampUnit.SECOND || u == ArrowType.TimestampUnit.MILLISECOND;\n}","tryCatchPattern":"try {\n    timestampWriter.writeToVector(vector, arrowType, value, rowIndex, allocator);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Unsupported Timestamp unit\")) {\n        throw new IllegalStateException(\"Cast column to timestamp(3) before writing to Lance\", e);\n    }\n    throw e;\n}","preventionTips":["Declare timestamp columns as millisecond precision (timestamp(3))","Cast micro/nano sources to millis in the upstream transform","Inspect the resolved Arrow schema before running the sink write"],"tags":["lance","arrow","timestamp","unsupported-unit","sink"],"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"}