{"record":{"id":"15e6b56b14080666","repo":"apache/seatunnel","slug":"unsupported-convert-value-getclass-to-long-t","errorCode":null,"errorMessage":"Unsupported convert ${value.getClass()} to Long, typeDefine: ${typeDefine}","messagePattern":"Unsupported convert (.+?) to Long, typeDefine: (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"seatunnel-api/src/main/java/org/apache/seatunnel/api/table/converter/BasicDataConverter.java","lineNumber":975,"sourceCode":"        if (value instanceof String) {\n            return convertLong(typeDefine, (String) value);\n        }\n        if (value instanceof Time) {\n            return convertLong(typeDefine, (Time) value);\n        }\n        if (value instanceof LocalTime) {\n            return convertLong(typeDefine, (LocalTime) value);\n        }\n        if (value instanceof Date) {\n            return convertLong(typeDefine, (Date) value);\n        }\n        if (value instanceof LocalDate) {\n            return convertLong(typeDefine, (LocalDate) value);\n        }\n        if (value instanceof LocalDateTime) {\n            return convertLong(typeDefine, (LocalDateTime) value);\n        }\n        throw new UnsupportedOperationException(\n                \"Unsupported convert \" + value.getClass() + \" to Long, typeDefine: \" + typeDefine);\n    }\n\n    default long convertLong(T typeDefine, Number value) {\n        return convertLong(value);\n    }\n\n    default long convertLong(T typeDefine, String value) {\n        return convertLong(value);\n    }\n\n    default long convertLong(T typeDefine, Time value) {\n        return convertLong(value);\n    }\n\n    default long convertLong(T typeDefine, LocalTime value) {\n        return convertLong(value);\n    }","sourceCodeStart":957,"sourceCodeEnd":993,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-api/src/main/java/org/apache/seatunnel/api/table/converter/BasicDataConverter.java#L957-L993","documentation":"Thrown by BasicDataConverter.convertLong(T typeDefine, Object value) when the value is neither a LocalDate nor a LocalDateTime (nor handled by subclass branches such as Number, since the shown generic path only accepts date types before throwing). The converter converts date-time values to epoch-backed longs; anything else is rejected with the value class and type definition in the message.","triggerScenarios":"Calling convertLong(typeDefine, value) with e.g. a String, Number outside the overloaded branch, java.util.Date, byte[] or a nested object where a LocalDate/LocalDateTime (or numeric) is required, when mapping a field to a BIGINT column.","commonSituations":"A source connector returns java.util.Date or String timestamps but the catalog declares BIGINT; after a library upgrade date handling moved from Number to LocalDate branches; custom transforms feed raw objects into long columns.","solutions":["Align the field schema with the converter expectations: declare the column as TIMESTAMP if the value is a date, or convert the value to Number/LocalDate before conversion","If the value is java.util.Date or String, convert it: toInstant().toEpochMilli() or LocalDate.parse(...)/Long.parseLong(...) before calling convertLong","Override convertLong(T typeDefine, Object value) in a custom converter to add the missing class branch"],"exampleFix":"// before\nlong l = converter.convertLong(typeDefine, row.getField(0)); // java.util.Date throws\n// after\nObject v = row.getField(0);\nlong l = (v instanceof java.util.Date)\n        ? ((java.util.Date) v).toInstant().toEpochMilli()\n        : converter.convertLong(typeDefine, v);","handlingStrategy":"type-guard","validationCode":"Object v = row.getField(0);\nif (!(v instanceof Number) && !(v instanceof LocalDate) && !(v instanceof LocalDateTime)) {\n    throw new IllegalArgumentException(\"Value \" + v.getClass() + \" is not convertible to LONG\");\n}","typeGuard":"static boolean isLongConvertible(Object v) {\n    return v instanceof Number || v instanceof LocalDate || v instanceof LocalDateTime;\n}","tryCatchPattern":"try {\n    l = converter.convertLong(typeDefine, value);\n} catch (UnsupportedOperationException e) {\n    LOG.warn(\"Inconvertible value {} for BIGINT: {}\", value, e.getMessage());\n    l = 0L;\n}","preventionTips":["Normalize java.util.Date/Strings to LocalDateTime/epoch millis before row conversion","Keep timestamp column types as TIMESTAMP in the catalog, not BIGINT, unless you convert yourself","Add converter unit tests for all temporal types your source produces"],"tags":["java","type-conversion","unsupported-operation"],"backgroundTag":"type-mismatch","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}